Dave Methvin schrieb:
$(function(){ $(#second,#first)[0].focus() });
Good job, Dave! Can't think of any way to get that any shorter.
$($(#second,#first)[0].focus);
It is a reference, right? Oh please!
Unfortunately, typeof(element.focus)!= function in IE (and I have scars to
prove it)
Absolutely correct, Sam.
I was going insane, I thought... :)
Gerry
On 1/15/07, Sam Collett [EMAIL PROTECTED] wrote:
http://blog.danen.org/
Gerry
In answer to the question on your blog, I think the fields are like
that because of the Google Toolbar form filling feature.
John Resig schrieb:
I'd try something like this:
$(function() {
var field = $(#second_field_to_enter)[0];
if ( field ) {
field.focus();
} else {
$(#first_field_to_enter)[0].focus();
}
});
That might get you at your desired goal.
Klaus Hartl schrieb:
$(function() {
var field = $(#second_field_to_enter)[0] ||
$(#first_field_to_enter)[0].focus();
field.focus();
});
How about..
$(function() {
( $(#second)[0] || $(#first)[0] ).focus();
});
--
Jörn Zaefferer
http://bassistance.de
Jörn Zaefferer schrieb:
Dave Methvin schrieb:
$(function() {
( $(#second)[0] || $(#first)[0] ).focus(); });
Wow, the way you guys waste keystrokes it's a wonder you get anything done.
:-)
$(function(){ $(#second,#first)[0].focus() });
Good job, Dave! Can't think of any way to
$(function(){ $(#second,#first)[0].focus() });
Good job, Dave! Can't think of any way to get that any shorter.
$($(#second,#first)[0].focus);
It is a reference, right? Oh please!
Unfortunately, typeof(element.focus)!= function in IE (and I have scars to
prove it) so it wouldn't be
In this piece of code (common to a number of pages) I want to set
focus to a second input field if there is one.
$(function() {
$(#first_field_to_enter)[0].focus();
$(#second_field_to_enter)[0].focus();
});
If the second input field is present, focus is on the second field. If
Try:
if($(#second_field_to_enter).size() 0) {
$(#second_field_to_enter)[0].focus();
}
I'd be interested to hear if there's a better way.
--Erik
On 1/15/07, Gerry Danen [EMAIL PROTECTED] wrote:
In this piece of code (common to a number of pages) I want to set
focus to a second input field
I'd try something like this:
$(function() {
var field = $(#second_field_to_enter)[0];
if ( field ) {
field.focus();
} else {
$(#first_field_to_enter)[0].focus();
}
});
That might get you at your desired goal.
--John
On 1/15/07, Gerry Danen
Thank you, Erik.
Works great, and no more errors!
There may be a better way (seems like there are several ways to do the
same thing, from what I've seen so far), but I'll stick with this
until something slick comes along.
Gerry
On 1/15/07, Erik Beeson [EMAIL PROTECTED] wrote:
Try:
Or try
$(function() {
$('#second_field_to_enter,#first_field_to_enter')[0].focus();
});
Karl Rudd
On 1/16/07, Gerry Danen [EMAIL PROTECTED] wrote:
In this piece of code (common to a number of pages) I want to set
focus to a second input field if there is one.
$(function() {
That works too, Karl.
Can you explain how it works?
An interesting thing I just noticed in IE7 is that on
http://test.danen.org/secure/register.htm the first, second, and
fourth fields are yellow. Bizarre. If this list allows attachments, I
can share a partial screenshot. Otherwise check the
A jQuery object is an array of 1 or more objects. I'm going to
simplify things down a little.
$('#B, #A')[0].focus();
The selector #B, #A tries to find objects with ids of B and A
(in that order). If B is not present in the document then it's just
not in the list, so A is the first element
Thank you, Karl.
As I learn, I'm sure this will make perfect sense. Actually, the logic
does make sense, just got to figure out where DOM fits in.
Just posted a rant about IE7. I think it's broken...
http://blog.danen.org/
Gerry
On 1/15/07, Karl Rudd [EMAIL PROTECTED] wrote:
A jQuery object
On 16/01/07, Gerry Danen [EMAIL PROTECTED] wrote:
Thank you, Karl.
As I learn, I'm sure this will make perfect sense. Actually, the logic
does make sense, just got to figure out where DOM fits in.
Just posted a rant about IE7. I think it's broken...
http://blog.danen.org/
Gerry
In
15 matches
Mail list logo