jQuery – attr() – removeAttr()
.attr() : Belirtilen nesnenin alt özelliklerine erişmeye yarar.
<img src="https://www.google.com/intl/en_ALL/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" alt="Google . . ." title="Google Her Yerde" ><br> <button id="title">Title Getir</button> <button id="titleChange">Title Değiştir</button>
$("#title").click(function () {
alert($("img").attr("title"));
});
$("#titleChange").click(function () {
$("img").attr("title", "Google Her Yerde.......");
alert($("img").attr("title"));
});
.removeAttr() : Belirtilen nesneden istenilen özniteliğin kaldırılmasını sağlar.
<img src="https://www.google.com/intl/en_ALL/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" alt="Google . . ." title="Google Her Yerde" ><br> <button id="title">Title Getir</button> <button id="titleRemove">Title Kaldır</button>
$("#title").click(function () {
alert($("img").attr("title"));
});
$("#titleRemove").click(function () {
$("img").removeAttr("title");
alert($("img").attr("title"));
});