When I create new attribute on element, which was dynamically generated, it's not saved:
$("#div-main").on("mouseover", ".generated", function(e)
{
console.log("hover");
console.log($(this).attr("title")) // always undefined
if (typeof $(this).attr("title") === typeof undefined)
{
$.get("<URL with PHP>", function(data)
{
if (data != "")
{
$(this).attr("title", data);
console.log($(this).attr("title")); // data shows
}
else
{
$(this).attr("title", "no data");
console.log($(this).attr("title")); // "no data" shows
}
});
}
else
{
console.log("'title' attribute already set");
}
});
#div-main
is not generated. Element with class .generated
is dynamically generated <a>
element.
Aucun commentaire:
Enregistrer un commentaire