我有以下HTML:JQUERY撥動兒童UL
<li class="helpClickable">What are the Terms of Service & Privacy Policy?</li>
<ul class="helpToggleAll">
<li class="helpContent"><span class="helpText">The Terms of Service are the Terms you agreed to when Creating an Account on this or any of the Gone Global Dating Network Sites.</span></li>
<li class="helpContent"><span class="helpText">The Privacy Policy is the Policy that Governs usage of your Personal Information stored in this Website and in the Gone Global Dating Network.</span></li>
<li class="helpContent"><span class="helpText">Click either link to re-read the document again - <a href="includes/legal/terms-of-use.php" target="_blank">Terms of Service</a> & <a href="includes/legal/privacy-policy.php" target="_blank">Privacy Policy</a>.</span></li>
<li class="helpContent"><span class="helpText">If you do not Agree with any part of either of these Documents then cease using this Website and the Gone Global Dating Network Imediendly.</span></li>
</ul>
我需要在點擊 'helpClickable' 上課的時候切換()的 'helpToggleAll' 類。 我一直在測試下面的代碼沒有成功。
var helpClickable = $('li.helpClickable');
helpClickable.click(function() {
$(this).children('ul').toggle();
});
切換()孩子的最佳方式是什麼?
thx
如上所述,'ul.helpToggleAll'不是'li'的孩子。因此,假設'li'元素*是父'ol'或'ul'的有效子元素,這會使您的標記無效。 「ul」或「ol」的***只有***有效的孩子是「li」元素。沒有其他人。將'ul.helpToggleAll'包裝在'li'中。 – 2012-02-12 00:46:38