开发者

JQuery Toggle Button Trigger

i have this code:

$('.access a').toggle(function() {
    $('link').attr('href', 'styles/accessstyles.css');
    $('body').css('font-size', '16px');
}, function() {
    $('link').attr('href', 'styles/styles.css');
    $('body').css('font-size', text_sizes[te开发者_开发问答xt_current_size] + 'px');
});

It works fine. But how would i programmatically trigger the toggle instead of clicking on it?


Like this:

$('.access a').trigger('click');

Since toggle is just functions that are swapped and executed on a click, that's what you want to trigger. Also available is the shortcut:

$('.access a').click(); //Same as first method
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜