i'm new with JQuery, and have problem with this
$("#trigger").click(
function(){
$("#pnel-menu").toggle("slow");
$(this).toggleClass("active");
$(this).attr("title", "Open Panel");
}, function() {
$(this).attr("title", "Close Panel");
return false;
});
HTML
<div id="pnel-menu">
menu
</div>
<p class="slidebar">
<a id="trigger" title="" href="#"></a>
</p>
<div id="pnel-cont">
Lorem ipsum dolor sit amet, consectetur adipiscing elit
</div>
what i like to do is to change the .trigger title dinamically when it clik to open or close the #pnel-menu.
But it wont change? does anyb开发者_开发问答ody can give some clue, thanks before :)
Try this:
$("#trigger").click(function(){
var that = $(this);
$("#pnel-menu").toggle("slow");
that.toggleClass("active");
that.attr("title", (that.hasClass("active")?"Close":"Open") + " Panel");
});
I don't think you should use two functions with ,
as a delimiter
$("#trigger").click(function(){
$("#pnel-menu").toggle("slow");
$(this).toggleClass("active");
if($(this).attr("title") == "Open Panel"){
$(this).attr("title", "Close Panel");
return false;
}
else
$(this).attr("title", "Open Panel");
});
Hope this works ^^
精彩评论