Example 1 — Official Toggle Title
Add and remove title on an input — the documented demo pattern.
var inputTitle = $("input").attr("title");
$("button").on("click", function () {
var input = $(this).next();
if (input.attr("title") === inputTitle) {
input.removeAttr("title");
} else {
input.attr("title", inputTitle);
}
$("#log").text("input title is now " + input.attr("title"));
}); How It Works
- Remember. Store the original
titleonce. - Compare. If it still matches, remove it.
- Restore. Otherwise set it back with
.attr().

