つまり、たくさんの要素があり、jQuery でそれらの 1 つだけを選択します。
($('div > ul > li').length === 1) // this is true
この要素を文字列として渡す必要がある場合、通常は次のようにします。
var el = $('div > ul > lu');
var passid = el.prop('id');
// in case this element doesn't have an id="..." attribute set one
if(typeof(passid)!=='string'){
// compute an id="..." attribute based on the time
var elindex = new Date().getTime();
// make sure the id we're using isn't already in use by a different element
while($('#el_'+elindex).length)
elindex++;
// assign what we've got
passid = 'el_'+ elindex ;
el.prop('id', passid);
};
passid = '#'+passid;
// Once we're good to go, pass the resulting selector
// passon(passid);... etc.
jQuery には、DOM ノードへの参照を文字列として渡すのを容易にする、より優れた (組み込みの) 関数 (または実際にはプラグイン) が付属していますか?