HTML
<div class="pop-circle Cats"></div>
CSS
.pop-circle { width:8px;height:8px;border-radius:4px;background-color:#50377A; }
JS
$(".pop-circle").attr("title", "blah");
Works as expected. However, later on (after user interaction) if I .append(mydiv) several more divs (Cats, Dogs, etc.) that have the same "pop-circle" class, the title attribute isn't added to them. Which makes sense, there was no new event. So what would you do?
My first idea was to do this:
$("div.pop-circle").hover( function() {
$(".Cats").attr("title", "cats");
$(".Dats").attr("title", "dogs");
// ...
});
I figure the hover should trigger even on divs that are appended after the page is loaded. However, this has a strange effect, the attribute isn't added, at least not the first few times I hover the div, or not at all. (Sorry I don't want to show a live example of the divs appending.)
I'm wondering if there's a more sensible way to do this.