$('.slideArrow').toggle(function (event) {
//some code
}, function (event) {
//some code
});这对于加载在页面加载上的内容来说很好,但是对于加载有ajax.It的内容,相同的函数不起作用,只是不截取点击。
我该怎么办?
在另一种情况下,我遇到了同样的问题(不是切换,而是点击),并以这种方式对其进行排序,我不知道如何处理切换?
$('.common-parent').on('click','.target-of-click',function(){
//some code
})发布于 2013-11-17 16:11:44
标志法:
var flag = false;
$(document).on('click', '.slideArrow', function(event) {
if (flag) {
// do one thing
}else{
// do another thing
}
flag = !flag;
});数据法
$(document).on('click', '.slideArrow', function(event) {
if ( $(this).data('flag') ) {
// do one thing
}else{
// do another thing
}
$(this).data('flag', !$(this).data('flag'));
});https://stackoverflow.com/questions/20032913
复制相似问题