我試圖做這樣的:如何將「this」用作選擇器的一部分?
$(this + ' li:not(:nth-last-child(2)):not(:last-child)').hide()
完整的代碼示例:
$('.comments').each(function(){
$(this + ' li:not(:nth-last-child(2)):not(:last-child)').hide()
var template = $('#expand').html();
$(this).prepend(template)
});
我需要運行它作爲一個「每個」功能全,因爲我想提出一個條件之後。
值得關注的是在幕後,所有的'$(選擇,背景)'所做的就是調用'$(上下文).find(選擇)':HTTP ://james.padolsey.com/jquery/#v=git&fn=jQuery.fn.init –
是的,'$(selector,context)'調用'$(context).find(selector)',但是**作品**。我不明白你的意思是「值得注意」......? – Zbigniew