Jump to content

simple jquery getting value


Rifts

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.