Button help | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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?

18th Dec 2017, 11:33 AM
JOHNTHEBUN
JOHNTHEBUN - avatar
3 Respostas
+ 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>
18th Dec 2017, 11:59 AM
James16
James16 - avatar
+ 3
getElementById("BtnA")
18th Dec 2017, 11:46 AM
Core i9
Core i9 - avatar
+ 3
yeah that's true. the ID is accessible for both CSS and JS and the ID must exist for use even in JS
18th Dec 2017, 12:02 PM
Core i9
Core i9 - avatar