Qual o erro do script? :s
15/04/2016
0
<!DOCTYPE html> <html> <body> <div class="example">Hello World.</div> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var x = document.getElementsByClassName("example"); window.alert(x); } </script> </body> </html>
Foxtery
Posts
15/04/2016
Raylan Zibel
<!DOCTYPE html> <html> <body> <div class="example" id="example">Hello World.</div> <button onclick="myFunction()">Try it</button> <script> function myFunction() { //var x = document.getElementsByClassName("example"); var x = document.getElementById("example"); window.alert(x.innerText); } </script> </body> </html>
Precisa ser pelo nome da classe?
15/04/2016
Foxtery
15/04/2016
Raylan Zibel
15/04/2016
Foxtery
<!DOCTYPE html> <html> <head> <title></title> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> </head> <body> <div class="example">Hello World.</div> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var x = $( ".example" ); window.alert(x.innerText); } </script> </body> </html>
15/04/2016
Raylan Zibel
<!DOCTYPE html> <html> <head> <title></title> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> </head> <body> <div class="example">Hello World.</div> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var x = $( ".example" ); window.alert(x.html()); // aqui } </script> </body> </html>
Clique aqui para fazer login e interagir na Comunidade :)