Also, what's Sean talking about when he says:
"lets say the focus function gets called twice (through
malicious javascript or a quirky browser) then the toggle state of the
class will be off. But in general I prefer your implementation. "
Is this something i need to worry about? Is this specif
On Apr 17, 2007, at 2:25 AM, Klaus Hartl wrote:
$(function(){
var toggle = function() { $(this).parent().toggleClass('on') };
$('fieldset").find('input, select, textarea').focus(toggle).blur
(toggle);
});
I'd choose this approach in order to avoid typing the class name
"on" in more
Thanks - funnily enough i downloaded firebug earlier on today.
Also, what's Sean talking about when he says:
"lets say the focus function gets called twice (through
malicious javascript or a quirky browser) then the toggle state of the
class will be off. But in general I prefer your implementati
> I'd choose this approach in order to avoid typing the class name "on" in
> more than one place (which may lead to errors if you want to change that
> one and forget it somewhere - not here maybe but in larger chunks of code).
It actually avoids duplicating the whole code to access the parent,
Klaus Hartl schrieb:
I'd choose this approach in order to avoid typing the class name "on" in
more than one place (which may lead to errors if you want to change that
one and forget it somewhere - not here maybe but in larger chunks of code).
It actually avoids duplicating the whole code to a
Sean Catchpole schrieb:
Hello,
Perhaps this would be a faster way of typing this (yet still easy to read):
$(function(){
$("fieldset").find("intput,select,textarea")
.focus(function(){ $(this).parent().addClass("on"); })
.blur(function(){ $(this).parent().removeClass("on"); });
});
In Firefox you can use the "Profile" feature of Firebug (
http://www.getfirebug.com ).
For most other browsers you'd have to stick with something like this:
var start = new Date().getTime();
// stuff to time
var milliseconds = (new Date().getTime()) - start;
Karl Rudd
On 4/17/07, [EMAIL PR
Thanks guys.
As it would be negligible, there's no need to worry.
But how would you test speed in js? (My background is php)
Aaron Heimlich wrote:
Off hand I'd have to say Sean's is faster, since it's only searching
for "every fieldset in the document" once instead of three times like
your
Good point Aaron. I agree, I think Sean's would be better, and clearer.
Karl Rudd
On 4/17/07, Aaron Heimlich <[EMAIL PROTECTED]> wrote:
Off hand I'd have to say Sean's is faster, since it's only searching for
"every fieldset in the document" once instead of three times like yours
(unless jQuer
Off hand I'd have to say Sean's is faster, since it's only searching for
"every fieldset in the document" once instead of three times like yours
(unless jQuery does some result caching that I'm not aware of, in which case
the difference is probably negligible). But, as Karl said, you'd really have
You'd have to test it. Could be either.
Karl Rudd
On 4/17/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Thanks guys. Very helpful.
So, which would be faster...
$("fieldset input, fieldset select, fieldset textarea")
or
$("fieldset").find("intput,select,textarea")
Thanks x 1,000
Thanks guys. Very helpful.
So, which would be faster...
$("fieldset input, fieldset select, fieldset textarea")
or
$("fieldset").find("intput,select,textarea")
Thanks x 1,000,000
Karl Rudd wrote:
You're on the right track.
Yes you can join (or "chain") the "focus" and "blur" functions to
You're on the right track.
Yes you can join (or "chain") the "focus" and "blur" functions together.
You also don't need to "return false" in the "focus" and "blur"
functions, as that would/should "cancel" the event.
You can also replace $(document).ready( function() {... with $( function() {..
Hello,
Perhaps this would be a faster way of typing this (yet still easy to read):
$(function(){
$("fieldset").find("intput,select,textarea")
.focus(function(){ $(this).parent().addClass("on"); })
.blur(function(){ $(this).parent().removeClass("on"); });
});
Also note that http://www.j
14 matches
Mail list logo