Forum Moderators: open

Message Too Old, No Replies

Jquery find string in html

         

Expo

6:57 pm on Dec 7, 2009 (gmt 0)

10+ Year Member



I've been using jquery for a few days and found myself in a function where I need to check the html contents of div for a phrase.

In javascript you just use innerHTML.indexOf , I tried

if($("#main").html().indexOf('Not Set')==-1) {}

but no joy

1. Is there a jquery method for this? I found 'contains' but it doesn't seem to work.

2. Is it possible to call the javascript version from inside a jquery function?

(Note that inside the div there are other divs that may contain the phrase. The main div id is 'main' and the child div ids are para1,para2,para3...)

Expo

1:43 am on Dec 8, 2009 (gmt 0)

10+ Year Member



ignore me

if($("#main").html().indexOf('Not Set')==-1) {}

Works absolutely fine - It's just case sensitive :s