jquery - IE7 failing to remove an element according to it's href attribute -


ah, ever on if there's still ie?

thanks invaluable of stack overflowers, have jquery working in ff, safari, chrome & oprah. naturally, fails in ie7, evidently has trouble href attributes, e.g.:

$('li a[href="' + title + '"]').parent().remove(); 

can shed light on alternative syntax ie7 understand remove un-checked item list? many in advance!

here's works:

<div class="product-module"> <div class="product-pic">     <div class="checkbox-wrapper">         <label for="compare1">             <input type="checkbox" class="checkbox" name="compare" id="compare1" />             compare         </label>     </div> </div>  <div class="product-info">     <p><a href="#" title="#"><span class="product-name">product name here</span></a></p>     </div> 

<div class="compare"> <ul> </ul> <p class="compare-button"><button type="submit">compare</button></p> <p class="clear-selections"><a class="button" id="clear-selections" href="#">clear selections</a></p> 

<script type="text/javascript">  // clear checkboxes on load $(function(){     $('input[type="checkbox"]').attr('checked', false); });   $(function(){     $('.column-main input[type="checkbox"]').click(function()    {         var title = $(this).closest('.product-module').find('.product-name').html();          // if user checks checkbox, add item ul         if    ($(this).attr('checked'))    {         var html = '<li><a href="'+title+'">' + title + '</a></li>';         $('.compare ul').append(html);          // un-checking checkbox removes corresponding item ul         }    else {         // $('.compare li a').attr('href', title).parent().remove();         $('li a[href="' + title + '"]').parent().remove();        //    works in real browsers; fails in ie7         }     }) });        $(function(){     $('.clear-selections').click(function(){         $('.compare ul').empty();         $('input[type="checkbox"]').attr('checked', false);     }) });   $(function(){     $('.compare button').click(function(){         minrequests = 2;         maxrequests = 3;         requested = $('.compare ul li').size();    // go figure: why not .length()?          if(requested < 2)    {         alert ('compare ' + requested + ' products?');          } else if((requested >= 2) && (requested <= 5 ))    {         alert ('there ' + requested + ' products compare');          } else {         alert (requested + ' many');         }     }); }); 

did compare title href of element? believe in ie uses absolute url instead of relative, may want double check href value before assuming work.

you may able use [href*= instead of href=

never assume, check. alerts on attr('href') , make sure match.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -