开发者

Exclude list item with jQuery not

开发者 https://www.devze.com 2023-01-17 19:43 出处:网络
How can I exclude the placeholder from being hovered? HTML: <ul class=\"listing\"> <li><p>red</p></li>

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

精彩评论

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

关注公众号