[jQuery] Re: first child

2009-04-09 Thread bart

Thank you all very much for replying. Mauricio's code worked for me :)

var el = $('#continer *:first').is('h2');
alert(el); // returns true if first child is H2, false otherwise

Again, thanks! :)

On Apr 7, 10:04 pm, Eric Garside gars...@gmail.com wrote:
 I think I understand what you want. Try this:

 $('#content :first-child')[0].tagName.toLowerCase(); // Will return
 a if it's an anchor, div for a div, img for an image tag, etc.

 On Apr 7, 12:37 pm, Mauricio \(Maujor\) Samy Silva

 css.mau...@gmail.com wrote:
   var $el = xx.is('h2'); //if it indeed matches a h2, returns true?

  
  var el = $('#continer *:first').is('h2');
  alert(el); // returns true if first child is H2, false otherwise.

  Maurício


[jQuery] Re: first child

2009-04-07 Thread Chuck Harmston
This will return the tag name of a container's first child:

$('#container  *')[0].tagName;

Hope it's useful!

Chuck Harmston
http://chuckharmston.com

On Tue, Apr 7, 2009 at 11:37 AM, bart b...@ivwd.nl wrote:


 Hello all,

 Let's say I'd have a div#content and I'd like to figure out what the
 first child of this div is. It could be an anchor, a paragraph, a
 heading who knows... I know the :first-child selector but this doesn't
 do what I want to accomplish as it just filters within the matched
 selector for the first child.

 Ultimately I'd like to figure out what element this first-child is. I
 can do this with .is() right?

 var $el = xx.is('h2'); //if it indeed matches a h2, returns true?

 Anyone willing to help out?


[jQuery] Re: first child

2009-04-07 Thread Mauricio (Maujor) Samy Silva




var $el = xx.is('h2'); //if it indeed matches a h2, returns true?


var el = $('#continer *:first').is('h2');
alert(el); // returns true if first child is H2, false otherwise.

Maurício 



[jQuery] Re: first child

2009-04-07 Thread Eric Garside

I think I understand what you want. Try this:

$('#content :first-child')[0].tagName.toLowerCase(); // Will return
a if it's an anchor, div for a div, img for an image tag, etc.



On Apr 7, 12:37 pm, Mauricio \(Maujor\) Samy Silva
css.mau...@gmail.com wrote:
  var $el = xx.is('h2'); //if it indeed matches a h2, returns true?

 
 var el = $('#continer *:first').is('h2');
 alert(el); // returns true if first child is H2, false otherwise.

 Maurício


[jQuery] Re: first child of type form control

2008-03-31 Thread dug

Thanks Jason :-)

How would I handle that if the #elHombre object is inside the form?

Cheers,
Dug


On Mar 27, 12:21 pm, Jason Huck [EMAIL PROTECTED] wrote:
 Try this:

 $('#elHombre').next('form').children('input select textarea')
 [0].focus();

 - jason

 On Mar 27, 6:32 am, DugFalby [EMAIL PROTECTED] wrote:

  Hi guys,

  I've got:

  $('#elHombre').focus();

  Which sets focus to a legend at the top of a form.

  I'd like to do:

  $('#elHombre').next-instance-of-tag-of-type==inputORtextareaORselect.focus();

  The page is set to scroll to the elHombre anchor. The focus needs to
  be set to thefirstform control that follows the anchor. For example:

  p id=elHombre
  This is the introduction/p
  form
  label
  Your name:
  input type=text //label
  /form

  The script would set the focus to the text input box.

  Thanks all :-)

  Best,
  Dug

  --
  DugFalby
  +44 75 15 66 16 55http://www.donkeyontheedge.com/


[jQuery] Re: first child of type form control

2008-03-31 Thread Richard D. Worth
$('form:has(#elHombre)').children('input, select, textarea')[0].focus();

- Richard

On Mon, Mar 31, 2008 at 6:12 AM, dug [EMAIL PROTECTED] wrote:


 Thanks Jason :-)

 How would I handle that if the #elHombre object is inside the form?

 Cheers,
 Dug


 On Mar 27, 12:21 pm, Jason Huck [EMAIL PROTECTED] wrote:
  Try this:
 
  $('#elHombre').next('form').children('input select textarea')
  [0].focus();
 
  - jason
 
  On Mar 27, 6:32 am, DugFalby [EMAIL PROTECTED] wrote:
 
   Hi guys,
 
   I've got:
 
   $('#elHombre').focus();
 
   Which sets focus to a legend at the top of a form.
 
   I'd like to do:
 
   $('#elHombre').next-instance-of-tag-of-type==
 inputORtextareaORselect.focus();
 
   The page is set to scroll to the elHombre anchor. The focus needs to
   be set to thefirstform control that follows the anchor. For example:
 
   p id=elHombre
   This is the introduction/p
   form
   label
   Your name:
   input type=text //label
   /form
 
   The script would set the focus to the text input box.
 
   Thanks all :-)
 
   Best,
   Dug
 
   --
   DugFalby
   +44 75 15 66 16 55http://www.donkeyontheedge.com/



[jQuery] Re: first child of type form control

2008-03-31 Thread Richard D. Worth
On second thought, you'll want to use .find, instead of .children, as the
elements could likely be within fieldsets and/or divs:

$('form:has(#elHombre)').find('input, select, textarea')[0].focus();

Also, here's another way to get the form from the #elHombre:

$('#elHombre').parents('form:first').find('input, select,
textarea')[0].focus();

- Richard

On Mon, Mar 31, 2008 at 6:26 AM, Richard D. Worth [EMAIL PROTECTED] wrote:

 $('form:has(#elHombre)').children('input, select, textarea')[0].focus();

 - Richard


 On Mon, Mar 31, 2008 at 6:12 AM, dug [EMAIL PROTECTED] wrote:

 
  Thanks Jason :-)
 
  How would I handle that if the #elHombre object is inside the form?
 
  Cheers,
  Dug
 
 
  On Mar 27, 12:21 pm, Jason Huck [EMAIL PROTECTED] wrote:
   Try this:
  
   $('#elHombre').next('form').children('input select textarea')
   [0].focus();
  
   - jason
  
   On Mar 27, 6:32 am, DugFalby [EMAIL PROTECTED] wrote:
  
Hi guys,
  
I've got:
  
$('#elHombre').focus();
  
Which sets focus to a legend at the top of a form.
  
I'd like to do:
  
$('#elHombre').next-instance-of-tag-of-type==
  inputORtextareaORselect.focus();
  
The page is set to scroll to the elHombre anchor. The focus needs to
be set to thefirstform control that follows the anchor. For example:
  
p id=elHombre
This is the introduction/p
form
label
Your name:
input type=text //label
/form
  
The script would set the focus to the text input box.
  
Thanks all :-)
  
Best,
Dug
  
--
DugFalby
+44 75 15 66 16 55http://www.donkeyontheedge.com/
 




[jQuery] Re: first child of type form control

2008-03-27 Thread Jason Huck

Try this:

$('#elHombre').next('form').children('input select textarea')
[0].focus();

- jason



On Mar 27, 6:32 am, Dug Falby [EMAIL PROTECTED] wrote:
 Hi guys,

 I've got:

 $('#elHombre').focus();

 Which sets focus to a legend at the top of a form.

 I'd like to do:

 $('#elHombre').next-instance-of-tag-of-type==inputORtextareaORselect.focus();

 The page is set to scroll to the elHombre anchor. The focus needs to
 be set to the first form control that follows the anchor. For example:

 p id=elHombre
 This is the introduction/p
 form
     label
     Your name:
     input type=text //label
 /form

 The script would set the focus to the text input box.

 Thanks all :-)

 Best,
 Dug

 --
 Dug Falby
 +44 75 15 66 16 55http://www.donkeyontheedge.com/