我有这样的HTML行:jQuery在点击时更改原始标题文本?
<div class="hide-btn top tip-s" original-title="Close sidebar"></div>
而当用户点击它,我想,该文本更改为“打开侧边栏”我怎么能做到这一点?
这是我的JS:
$(".hide-btn").click(function(){
if($("#left").css("width") == "0px"){
$("#left").animate({width:"230px"}, 500);
$("#right").animate({marginLeft:"250px"}, 500);
$("#wrapper, #container").animate({backgroundPosition:"0 0"}, 500);
$(".hide-btn.top, .hide-btn.center, .hide-btn.bottom").animate({left: "223px"}, 500, function() { $(window).trigger("resize");});
}
else{
$("#left").animate({width:"0px"}, 500);
$("#right").animate({marginLeft:"20px"}, 500);
$("#wrapper, #container").animate({backgroundPosition:"-230px 0px"}, 500);
$(".hide-btn.top, .hide-btn.center, .hide-btn.bottom").animate({left: "-7px"}, 500, function() { $(window).trigger("resize");});
}
});
谢谢您的时间!
[如何使用jQuery更改元素的标题属性](http://stackoverflow.com/questions/987967/how-to-change-an-elements-title-attribute-using-jquery)可能的重复..这会帮助你。 – 2012-04-07 09:54:33