Nitesh morajkar
Nitesh morajkar

Reputation: 431

jQuery :contains not working in ie7 (jQuery 1.3.5)

I'm trying to find a text inside a div. The code I have works in all browsers except IE7.

Below is the code:

<div class="demo"> 
   Preveiw
</div>

Jquery:

$(".demo:contains('Preveiw').length") // returns 0 in IE7

Upvotes: 3

Views: 512

Answers (2)

kamui
kamui

Reputation: 3419

It could be that jQuery has not loaded yet try putting your script at the bottom of the page within

 <script defer="defer">

which will rule that out and the code within

  $(document).ready(function() {
        alert($(".demo:contains('Preveiw')").length);
  });

which could be another problem.

here it is on jsFiddle http://jsfiddle.net/kamui/VfhQ6/2/

Upvotes: 1

Stefan
Stefan

Reputation: 5672

Try this instead

$(".demo:contains('Preveiw')").length

Upvotes: 4

Related Questions