Rifts Posted January 10, 2011 Share Posted January 10, 2011 I have a very simple example <body> <p>First Paragraph</p> <p>Second Paragraph</p> <p>Yet one more Paragraph</p> <script> $("p").click(function () { alert( $(this) ); //this is the line im messing with }); $("p").hover(function () { $(this).addClass("hilite"); }, function () { $(this).removeClass("hilite"); }); </script> </body> I just want to click and an alert will pop up displaying the text between the <p></p> I clicked but it only says [object Object] instead of "First Paragraph" Thanks Link to comment https://forums.phpfreaks.com/topic/223966-simple-jquery-getting-value/ Share on other sites More sharing options...
RichardRotterdam Posted January 10, 2011 Share Posted January 10, 2011 http://api.jquery.com/text/ http://api.jquery.com/html/ Link to comment https://forums.phpfreaks.com/topic/223966-simple-jquery-getting-value/#findComment-1157413 Share on other sites More sharing options...
Rifts Posted January 10, 2011 Author Share Posted January 10, 2011 thanks a ton figured it out! alert( $(this).text() ); it was so simple lol Link to comment https://forums.phpfreaks.com/topic/223966-simple-jquery-getting-value/#findComment-1157416 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.