English 中文(简体)
我需要帮助指定仅使用jQuery的顶级LI
原标题:I need help with specifying the top level LIs only using jQuery

我试图限制append函数,使其仅适用于顶级LI,但我显然不知道如何做到选择性。在过去的几天里,我一直在寻找能指引我朝着正确方向前进的东西,但到目前为止运气不佳。。。

我只想在顶级中使用向下箭头,在后续的LI中使用向右箭头。希望这会有意义。这是我正在使用的代码。

$("ul.dropdown li:has(ul)").find("a:first").append( <img class="down_arrow" border="0" style="padding-left:3px;" src="http://nunyabiz.zxq.net/img/down.gif" /> )
$("ul.dropdown li ul li:has(ul)").find("a:first").append( <img class="right_arrow" border="0" style="padding-left:3px;" src="http://nunyabiz.zxq.net/img/right.gif" /> );

查看完整代码:http://nunyabiz.zxq.net/menu/index.html

最佳回答

使用子选择器(”parent>;Child“)选择器

$("ul.dropdown > li:has(ul)").find("a:first").append(
    $("<img>", { 
        "class": "down_arrow", 
        border: 0, 
        style: "padding-left:3px;", 
        src: "http://nunyabiz.zxq.net/img/down.gif"
    })
);

或者你是怎么做到的:

$("ul.dropdown > li:has(ul)")
    .find("a:first")
    .append( <img class="down_arrow" border="0" style="padding-left:3px;" src="http://nunyabiz.zxq.net/img/down.gif" /> )

哪个还可以

问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签