开发者

Exclude list item with jQuery not

How can I exclude the placeholder from being hovered?

HTML:

<ul class="listing">
    <li><p>red</p></li>
    <li><p>green</p></li>
    <li><p>blue</p></li>
    <li id="li-placeholder"><p>placeholder</p></li>
</ul>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
开发者_如何转开发

JS:

$(function() {
    $(".listing > li > p").hover(function() {

    // exclude placeholder
    // try...
    // $(".listing > li > p").not("#li-placeholder").hover(function() {
    // $(".listing > li > p:not('#li-placeholder')").hover(function() {

        $(this).css("cursor", "help"); 
    });
}​)​


$(".listing > li:not(#li-placeholder) > p")

That is the selector you are after. See it.


you placed the placeholder marker on the LI not on the P. Try

$(function() {
  $(".listing>li:not(#li-placeholder)>p").hover(function() {
     $(this).css("cursor", "help"); 
  });
})

​ I Hope this will help you,

Jerome Wagner

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜