I'm having trouble getting write syntax for the equivalent of $ .each using delegates.
All the examples I read just show a click or a hang, but how would I start writing this using delegate syntax?
$("ul li a").each(function(){
$(this).addClass("foo");
});
Hooray!!
Edit: after a lot of comments (thanks, by the way), I thought it was better to post a more explicit example. We apologize for the lack of detail in my previous question.
Say, for example, I want to snap tooltips to anchors on a page. I will have many elements that I want to configure as hints, and I want to reduce memory overhead by using delegation.
As I understand it, so I would start:
$(document).delegate("a.tooltip", "click", function(event){
}).delegate("a.tooltip", "hover", function(event){
});
, title, . , ( ), hover, , .
- :
$("a.tooltip").each(function () {
$.prop(this, "data-old-title", $.attr(this, "title"));
}).removeAttr("title");
?
, , , - .