多个 .of('click'... 函数仅绑定到第一个 <div>
Multiple .on('click'... function binded only to 1st <div>
我有 .on('click) 函数只在第一个 div 上工作,因为我使用变量来控制它。这是按钮代码:
$('.article.active').on('click',function(){
var $currentArticleInfo = $('.articleInfo.active');
var $current = $('.article.active');
$current.effect('slide',{direction:'up',mode:'hide'});
$currentArticleInfo.animate({top:0});
});
和 JSfiddle:http://jsfiddle.net/u5nw3bhz/3/(我正在使用 Jquery Mobile 中的 'swipe' 方法。切换到 'Toggle device mode')
试试这个:
$('body').on('click', '.article.active', function () {
// do stuff
});
这里应该使用委托
$('body').delegate('.article.active', 'click', function () {
All_Your_code_Goes_here
});
我有 .on('click) 函数只在第一个 div 上工作,因为我使用变量来控制它。这是按钮代码:
$('.article.active').on('click',function(){
var $currentArticleInfo = $('.articleInfo.active');
var $current = $('.article.active');
$current.effect('slide',{direction:'up',mode:'hide'});
$currentArticleInfo.animate({top:0});
});
和 JSfiddle:http://jsfiddle.net/u5nw3bhz/3/(我正在使用 Jquery Mobile 中的 'swipe' 方法。切换到 'Toggle device mode')
试试这个:
$('body').on('click', '.article.active', function () {
// do stuff
});
这里应该使用委托
$('body').delegate('.article.active', 'click', function () {
All_Your_code_Goes_here
});