English 中文(简体)
• 如何选择儿童,但不是 j(姓名相同)的根源
原标题:How to select children but not the root element (with same name) in jQuery

页: 1 我有一些与根源相同的孩子。 我正在寻求一种办法,只选择这些儿童的内容,而不只是根本内容。 我先看着 j子的挑选者的文件,og一nch,但我所能发现的唯一东西是那些正面临相反问题的人:选择儿童和根源,这是对我来说非常出色的工作(罚款:)!

例如,XML:

<myElement>
    <someElementWithVariableName>
        <someMoreVariationElement>
            <myElement>
                <leafNode1/>
                <leafNode2/>
            </myElement>
            <myElement/>
        </someMoreVariationElement>
    <someElementWithVariableName>
</myElement>

现在,我会收到2个目标:一些More VariationElement的根源和2个儿童要素:

$(inputXml).find("myElement")

我很想知道,或许我可以使用

$(inputXml).find("myElement > *")

但是,只有在我的执行要素是实际的的情况下,这种工作才会奏效,但不能保证。 它可以是别的。 同一些ElementWithVariableName和一些MoreVariation 既可以是任何东西。 基本原理 我需要一名选择人,如果是某个孩子的话,他们只能获得我的证言。

(如果只选择第3级的所有属性(将根数定为0级,将一些ElementWithVariableName定为1级,将一些MoreVariationElement定为2级)的话,那将更好。

最佳回答
问题回答




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