要素の値をチェックしようとしていますが、クラスをチェックしているときにはundefined
を返します。要素の値を取得する
HTML:
<div class='cube' value='test' onclick='checkCube(this)'></div>
はJavaScript:
function checkCube(cube) { // - there's either one of those lines, not both)
var check = cube.value; //This is not working,
var check = cube.className; //This is.
console.log(check);
}
私はそれを空の要素にしたいので、それにはテキストは含まれません。 既にgurviner372によって解決策が得られています。 ありがとうとにかく:D – Omer