buzzersdad
New member
This works as shown, but if you include the "if" statement, it doesn't work. (I'm new at this, and have searched everywhere I know of to find what's wrong - it must be simple)
<!DOCTYPE html>
<html>
<body>
<style>
.box { width: 80px; height: 80px; margin: 0px; padding:0px; border: 1px solid black; position: absolute; }
</style>
<script>
function swap(id) {
var a=document.getElementById(id).getAttribute("value")
// if a == "x" {
document.write(a);
// }
}
</script>
<div class="box" onclick="swap('00')" id="00" value="x"
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<style>
.box { width: 80px; height: 80px; margin: 0px; padding:0px; border: 1px solid black; position: absolute; }
</style>
<script>
function swap(id) {
var a=document.getElementById(id).getAttribute("value")
// if a == "x" {
document.write(a);
// }
}
</script>
<div class="box" onclick="swap('00')" id="00" value="x"
</div>
</body>
</html>