JQuery .click() function or .text() not changing text -
i don't know why following code won't change "hi" "does work" when button clicked. i'm pretty new jquery i've seen nothing here wrong. great. thanks!
<!doctype html> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#btn1").click(function(){ $("#textplace").text("does work?"); }); }); </script> </head> <body> <label>text should appear here</label> <p id="textplace">hi</p> <button id="btn1">click here</button> </body> </html>
i have jquery "btn1" being button , "textplace" being <p>
. paragraph hardcoded "hi". when click button, text not change. both btn1 , textplace id button , p
try this:
$("#btn1").click(function () { $("#textplace").prev('label').text("does work?"); });
Comments
Post a Comment