我正在尝试检查一个元素的值,但它返回undefined虽然它在我检查它的类时有效.
HTML:
<div class='cube' value='test' onclick='checkCube(this)'></div>
Run Code Online (Sandbox Code Playgroud)
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);
}
Run Code Online (Sandbox Code Playgroud)