+ 3
Button help
HTML: <button type=âbuttonâ id=âBtnAâ onclick=â?()â CSS: #BtnA { âStyleâ } JS: function ?() { var a = âHelloâ; document.getElementById(â001â).innerHTML = a( } -end- How can i make the button execute the code?
3 Answers
+ 3
<!--I think you need to put on a real id, that's the code that I remade! you can see it :) -->
<button type = "button" id = "BtnA" onclick = "Func()"> click </button>
<script>
function Func() {
var a = "Hello";
document.getElementById ("BtnA"). innerHTML = a;
}
</script>
+ 3
getElementById("BtnA")
+ 3
yeah that's true. the ID is accessible for both CSS and JS and the ID must exist for use even in JS