jQuery如何在toggle上更改父div的类
|
当我滑动我拥有的简单手风琴时,我想更改链接元素的类和.revealBox div,它根据手风琴是打开还是关闭来包装整个手风琴
我的jQuery是
$(document).ready(function() {
// choose text for the show/hide link - can contain HTML (e.g. an image)
var showText = \'Hide Information\';
var hideText = \'Show Information\';
var is_visible = false;
$(\'.collapseLink\').append(\'<span class=\"dottedBot\">\' + showText + \'</span>\');
$(\'.revealBoxContents\').show();
$(\'a.collapseLink\').click(function() {
// switch visibility
is_visible = !is_visible;
// change the link depending on whether the element is shown or hidden
$(this).html((!is_visible) ? showText : hideText);
// toggle the display - uncomment the next line for a basic \"accordion\" style
//$(\'.toggle\').hide();$(\'a.toggleLink\').html(showText);
$(this).parent().next(\'.revealBoxContents\').slideToggle(\'slow\');
// return false so any link destination is not followed
return false;
});
// toggle the bottom link
$(\'.collapseLink\').click(function() {
$(this).parents(\'.revealBoxContents\').stop(true, true).slideToggle(\'slow\');
$(\".collapseLink\").html((!is_visible) ? showText : hideText);
$(this).parent(\'.item\').toggleClass(\'current\');
});
});
我的网址是
http://satbulsara.com/NSJ-local/eqs1.htm
谢谢,
周六
没有找到相关结果
已邀请:
2 个回复
版萍层分
http://api.jquery.com/toggleClass/
耐钨徒