9 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
ramblingwood says
I enjoyed the article. There is something that I lack understanding of in the Javascript. Could you point out what is the mechanical or programmatic connection when the pointer is moved off the links? I was expecting to see a function name like onHoverOff, or something of that nature. I don’t see how the script know what function to execute when the cursor moves off the links. Thanks!
In Javascript it is onmouseout . In jQuery, it is the the second argument in click. Example:
$('#something').click(function () {
// onmouseover
}, /* second argument!! */ function () {
// onmouseout
});
3 posts
  • Has been a member for 4-5 years
williamrouse says
I enjoyed the article. There is something that I lack understanding of in the Javascript. Could you point out what is the mechanical or programmatic connection when the pointer is moved off the links? I was expecting to see a function name like onHoverOff, or something of that nature. I don’t see how the script know what function to execute when the cursor moves off the links. Thanks!
In Javascript it is onmouseout . In jQuery, it is the the second argument in click. Example:
$('#something').click(function () {
// onmouseover
}, /* second argument!! */ function () {
// onmouseout
});

So, is this an example of the dreaded call back function?

9 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
ramblingwood says
I enjoyed the article. There is something that I lack understanding of in the Javascript. Could you point out what is the mechanical or programmatic connection when the pointer is moved off the links? I was expecting to see a function name like onHoverOff, or something of that nature. I don’t see how the script know what function to execute when the cursor moves off the links. Thanks!
In Javascript it is onmouseout . In jQuery, it is the the second argument in click. Example:
$('#something').click(function () {
// onmouseover
}, /* second argument!! */ function () {
// onmouseout
});
So, is this an example of the dreaded call back function?

No, a callback function is usually a function that is run after completion of code, where as this is just and argument to the method ‘click’.

2 posts
  • Bought between 1 and 9 items
  • Has been a member for 6-7 years
aaronworks says
@aaronworks I don’t see how a generic Javascript book would cover things specifically about jQuery.

@ramblingwood When I bought the book (and yes, I BOUGHT the book), I thought it would be just a generic book on JavaScript too. But I was nicely surprised that the author decided to devote a large part of the book to using jQuery. He thinks jQuery is the most accessible cross-browser framework whose syntax is easy to learn and use. I think this book provides a great foundation for delving into the actual jQuery site, as well as introduced me to a lot of useful jQuery plugins. So much so, I also bought the PDF version as a portable reference.

But your article also provides good learning points for the new jQuery programmer to keep in mind.

3 posts
  • Has been a member for 4-5 years
williamrouse says
I enjoyed the article. There is something that I lack understanding of in the Javascript. Could you point out what is the mechanical or programmatic connection when the pointer is moved off the links? I was expecting to see a function name like onHoverOff, or something of that nature. I don’t see how the script know what function to execute when the cursor moves off the links. Thanks!
In Javascript it is onmouseout . In jQuery, it is the the second argument in click. Example:
$('#something').click(function () {
// onmouseover
}, /* second argument!! */ function () {
// onmouseout
});
So, is this an example of the dreaded call back function?
No, a callback function is usually a function that is run after completion of code, where as this is just and argument to the method ‘click’.

OK! Let me look at the syntax of the two more closely.

9 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
ramblingwood says
@aaronworks I don’t see how a generic Javascript book would cover things specifically about jQuery.

@ramblingwood When I bought the book (and yes, I BOUGHT the book), I thought it would be just a generic book on JavaScript too. But I was nicely surprised that the author decided to devote a large part of the book to using jQuery. He thinks jQuery is the most accessible cross-browser framework whose syntax is easy to learn and use. I think this book provides a great foundation for delving into the actual jQuery site, as well as introduced me to a lot of useful jQuery plugins. So much so, I also bought the PDF version as a portable reference.

But your article also provides good learning points for the new jQuery programmer to keep in mind.

Oh! That’s great! The title led me to believe otherwise, but I didn’t Google it either. Interesting. I might borrow the book from the library.

1 post
  • Bought between 1 and 9 items
  • Has been a member for 4-5 years
bganicky says

Hi,

in the 2nd example you say that:
// text is equal to 'Content #2!'
var text = $("#wrapper .box")[1];
As far as [] returns DOM elements, the text variable can’t possibly be a string. The code must have been like this instead:
// text is equal to 'Content #2!'
var text = $("#wrapper .box").eq(1).text();
4 posts
  • Has been a member for 4-5 years
  • Referred between 1 and 9 users
  • United States
jaredwilli says

The callback thing is definitely the most useful thing I found here.

$(this) is another thing that can be very confusing to new people too, (me). I know theres some other tips I found useful too, since I am reading the O’Reilly book jQuery Cookbook, but I can’t remember them. I should re-read it from the beginning again.

1 post
  • Has been a member for 4-5 years
aarontgrogg says

In item #1, wouldn’t this: var testText = $('div#test').text();

Perform better if written like this? var testText = $('#test').text();

The initial declaration means jQuery will collect and loop through all the DIVs in the page looking for the one with the ID of “test”, whereas the revised declaration will simply get the element that has the ID of “test”, right?

Thanks, Atg

9 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
ramblingwood says
In item #1, wouldn’t this: var testText = $('div#test').text();

Perform better if written like this? var testText = $('#test').text();

The initial declaration means jQuery will collect and loop through all the DIVs in the page looking for the one with the ID of “test”, whereas the revised declaration will simply get the element that has the ID of “test”, right?

Thanks, Atg

I don’t know, but I would imagine that jQuery is optimized enough to detect that because it is a large time savings.

by
by
by
by
by
by