jquery show/hide button to change tooltip
I have the jquery code bel开发者_StackOverflow中文版ow that changes the text in the button to show/hide but I would also like to change the tooltip/title when the button is hovered over with the mouse to also say show/hide
$('#HideShow').click(function()
{
if ($(this).text() == "Show")
{
$(this).text("Hide");
}
else
{
$(this).text("Show");
};
});
How can I use jquery to also change the tooltip/title to show/hide when the button is changed?
$('#HideShow').click(function() {
if ($(this).text() == "Show") {
$(this).text("Hide").attr("title", "Hide");
} else {
$(this).text("Show").attr("title", "Show");
}
});
use the attr command
so $(this).attr("attribute to change", "new value");
精彩评论