+ 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 Respuestas
+ 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