Hello, I'm learning jQuery now, and was reading an article of Jeffrey Way, "You Still Can’t Create a jQuery Plugin?" Almost everything is clear, but there are some points that I still cannot understand.
Problems begin on the 'Step 3: Building the Plugin', heading title 'For Each...', and next 'Error Checking'.
this.each(function() {
$this = $(this);
var title = this.title;
if ($this.is('a') && $this.attr('title') != '') {
this.title = '';
$this.hover(function(e){
Questions
this.title- what a method is it? When we use jQuery we type$(this).attr('title')- and jQuery was created to simplify development) Doesthis.titlerefer to a DOM Specification, or Javascript built-in methods?I totally cannot understand what is going on with
thiskeyword here, when do we have to usethisand when$(this)? Why do we usethis.each(func..., and not$(this).each(func...? (I've tested it - and it works too, but what is a difference?) I know that factory method$()returns a wrapped set of DOM elements, but why do we usethis.titlehere (and again$(this).attr('title')does the job)? I made a little bit of testing. We can typethis.titleortitleinstead of$this.attr('title')in the conditional statement, but if only we use anything (titleor$(this).attr('title')) instead ofthis.titlein the statementthis.title = '';- it doesn't work.Well, we specified
var title = this.title;. But when we use this variable, why do we declare it?
I think that some of you can understand even better than me, understanding of what things I need, so I finish my explanation) Thank you very, very much, if you can make it clear)