English 中文(简体)
如何找到点击儿童的父母指数[复制]
原标题:How can i find the index of parent clicking child [duplicate]
  • 时间:2012-04-05 13:18:10
  •  标签:
  • jquery

在点击儿童时,我想知道父母指数第1号。 例如,当我点击每ul孩子时,就有一个四分三ul子,应该显示其母子的母子指数。 我如何能够做到这一点?

j 质量:

$( .opSection ).on( click , li ,function(){

    var num = $(this).parent( ul ).index();

    alert(num);

    //alert(chartData.Indices[$(this).index()][$(this).index()]);

    })

传真:

    <div class="opSection">//parent of all
<dl><dd>
        <ul class="selectGroup" title= allIndia  data-select= 1 >
            <li data-index="123" class="c_on">All India</li> // when i click any of li i need 0
        </ul>

        <ul class="selectGroup" title= allIndia  data-select= 1 >
            <li data-index="123" class="c_on">All India</li> // when i click this, i need 1
        </ul>
</dd></dl>
    </div>
最佳回答
$( .opSection ).on( click ,  li , function () {
    alert($(this).parent().index();
});

我利用活动代表团在为多个要素处理事件时改进业绩。

这里的重要部分是:0000(,以选择<代码>ul,然后是>

http://www.ohchr.org。 你在评论中说,你的标记与你在座标的相同,而是试图:

$( .opSection ).on( click ,  li , function (e) {
    $(e.delegateTarget).find( .selectGroup ).index(this.parentNode);
});

<代码>(e.delegateTarget)与$(op Section )相同(但较快)。 然后,我们搜索所有后代(find(),供所有<代码><ul/> s,并使用相同的方法查找我们点击的位置。

问题回答

暂无回答




相关问题
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: &...

热门标签