复制代代码如下: 無标题文档 <!-- <BR>$(function(){ <BR>$("#aDescendant").click(function(){ <BR>$ ("#結果").html(""); <BR>$("#div1 ul").each(function(){ <BR>$("#結果").html($("#結果" ).html() $(this).html() "," ); <BR>}) <BR>}) <BR>$("#aChild").click(function(){ <BR>$( "#Result").html(""); <BR>$("#div1 > li").each(function(){ <BR>$("#Result").html($("#Result ").html() $(this).attr("id") "," ); <BR>}) <BR>}) <BR>$("#aNext").click(function(){ <BR>$("#Result").html(""); <BR>$("ラベル入力").each(function(){ <BR>$("#Result").html($("#結果").html() $(this).attr("value") ","); <BR>}) <BR>}) <BR>$("#aSibling").click(function(){ <BR>$("#Result").html(""); <BR>$("#input1 ~ label").each(function(){ <BR>$("#Result").html($ ("#Result").html() $(this).html() ","); <BR>}) <BR>}) <BR>}) <BR>// --></スクリプト> <BR> <br><br><本体> <BR><div id="div1"> <BR><li id="l1"> <BR><ul>1 <BR><ul>2 <BR><ul>3 <BR><ul>4 <BR> <BR><li id="l2"> <BR><ul>一 <BR><ul>二 <BR><ul>三 <BR><ul>四 <BR> <BR><label>Label1 <BR><input id="input1" value="input1" /> <BR><入力/> <BR><label>Label2 <BR><label>Label4 <BR> Label3 Label4 表示DIVの後序结点ID 表示DIV の子LI结点 ラベルの下の入力要素の値を表示 input1 要素と同じ階層のラベル要素の内容を表示します 結果: