My Html looks like this:
<a href="#" id="QuoteTest">Click Here</a>
<ul>
<li title="this" style="position:relative">one</li>
<li title="this" style="position:relative">two</li>
<li title="tha't" style="position:relative" >three</li>
<li title="tha't" style="position:relative">four</li>
</ul>
Jquery:
$('a#QuoteTest').click(function() {
$('li[title=this]').animate({ 'left': '+=40px' }, 'slow');
$("li[title=tha't]").animate({ 'top': '+=40px' }, 'slow');
});
I can't get the selector to work with a single quote in it. I tried escaping the quote with a, "\", backslash but that didn't help.
Any ideas on what is proffered way?
Try two
$("li[title=tha\\'t]").animate({ 'top': '+=40px' }, 'slow');
None of these worked for me in IE, so I had to use filter():
$("li").filter(function(index){
return $(this).attr("title") == "tha\'t";
})
.animate({ 'top':'+=40px' }, 'slow');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With