我有一个id='user‘的div。如果客人来访,有登录表和登记表。我使用标签在登录和注册表单之间切换。
jQuery(function() {
jQuery('.box a').livequery('click', function(e){
switch_tabs(jQuery(this));
});
switch_tabs(jQuery('.defaulttab'));
function switch_tabs(obj){
jQuery('.box-content').hide();
jQuery('.box a').removeClass('selected');
var id = obj.attr("rel");
jQuery('#'+id).show();
obj.addClass("selected"); }
});在用jquery加载函数(jQuery('#user').load(location.href+' #user'))按下登录或注册按钮之后,我重新加载了div标记(#user)
然后只有一个注销按钮。当按下该按钮时,它将销毁php中的会话并重新加载#user div
jQuery(function(){
jQuery('#off').livequery('click', function(e){
jQuery('.loader').html('<img src="img/loader.gif" />').show();
jQuery.post('process/logoff.php', null, function(data){
jQuery('#user').load(location.href+' #user');
jQuery('.loader').hide();
});
});
});重新加载后,我的switch_tab函数将不起作用,并显示两者(注册和登录div)。为什么会发生这种情况,我该如何修复它?
发布于 2013-05-05 07:28:13
如果你使用的是更新版本的jQuery,你不应该使用:.on()吗?
难道你不想引用'id‘而不是'rel’吗?
var id = obj.attr("id");如果您正在尝试引用您正在显示的内容的id。
https://stackoverflow.com/questions/15338213
复制相似问题