QuepasaTio QuepasaTio - 4 months ago 11
jQuery Question

jQuery Onclick event on specific h2 containing specific text

I have a div that has been included into my page dynamicly so I don't have access to it as it's not on my current page.

This is how it looks:

<h2 class="title">About</h2>

What I need to do is to add an 'onclick' event that targets this div.

All I know is that it's a 'h2' with a class of 'title' and with text containing 'About'.

How can I do this?


you can use :contains to select also contained text like this:

$("h2.title:contains('About')").click(function(e) {
    // Handle here