[jQuery] Re: Trying to set the id of a 2nd level div and failing

2008-01-16 Thread Alexey Blinov
BTW id attribute must be unique as i know... I know you can omit it but its
not fair.
OK. did you try to use contents( )?

something like this (untested) $('#obj').contents().filter('div').attr('id',
'Bob')?

On Jan 16, 2008 2:20 AM, Wizzud [EMAIL PROTECTED] wrote:


 Use find()?
 The children() function (should) return unique immediate children
 which won't get you your second level divs in a single call from the
 #obj level, no matter what selector you use.

 eg...
 var obj = $(#obj);
 obj.find(.obj_level1.obj_level2).attr( id, Bob );


 On Jan 15, 6:03 am, Mark Lacas [EMAIL PROTECTED] wrote:
  I'm trying to set the id of a 2nd level obj selected by class and it
  doesn't seem to work as I thought it would.
 
  Unfortunately all of the level one objects get the id assignment, not
  the level two object.
 
  Here it is before I do the operation:
 
  div id=obj
  div class=obj_level1
  div class=obj_level2/div
  /div
  div class=obj_level1.1/div
  /div
 
  Then I do this:
 
  var obj = $(#obj);
  //bunch of code
  obj.children(.obj_level1  .obj_level2).attr( id, Bob );
 
  It ends up like this:
 
  div id=obj
  div id=Bob class=obj_level1
  div class=obj_level2/div
  /div
  div id=Bob class=obj_level1.1/div
  /div
 
  Note the two divs with the same id. . .
 
  Do I have to use:
 
  obj.children(.obj_level1).children(.obj_level2).attr( id,
  Bob );
 
  Originally I was using:
 
  $(#obj  .obj_level1  .obj_level2).attr( id, Bob );
 
  And that worked ok, but I needed the object in a variable as I and
  using it repeatedly and didn't want to dereference it every time I use
  it, for speed's sake.
 
  Any thoughts as to the correct syntax to do this?
 
  Thanks,
  ml



[jQuery] Re: Trying to set the id of a 2nd level div and failing

2008-01-16 Thread Mark Lacas

Thanks,
  I was wondering if that was the way I had to go.
Is find the fastest in terms of cpu cycles?  It sounds like it might
not be by its name.  That's why I didn't use it.
ml

On Jan 15, 3:20 pm, Wizzud [EMAIL PROTECTED] wrote:
 Use find()?
 The children() function (should) return unique immediate children
 which won't get you your second level divs in a single call from the
 #obj level, no matter what selector you use.

 eg...
 var obj = $(#obj);
 obj.find(.obj_level1.obj_level2).attr( id, Bob );

 On Jan 15, 6:03 am, Mark Lacas [EMAIL PROTECTED] wrote:

  I'm trying to set the id of a 2nd level obj selected by class and it
  doesn't seem to work as I thought it would.

  Unfortunately all of the level one objects get the id assignment, not
  the level two object.

  Here it is before I do the operation:

  div id=obj
  div class=obj_level1
  div class=obj_level2/div
  /div
  div class=obj_level1.1/div
  /div

  Then I do this:

  var obj = $(#obj);
  //bunch of code
  obj.children(.obj_level1  .obj_level2).attr( id, Bob );

  It ends up like this:

  div id=obj
  div id=Bob class=obj_level1
  div class=obj_level2/div
  /div
  div id=Bob class=obj_level1.1/div
  /div

  Note the two divs with the same id. . .

  Do I have to use:

  obj.children(.obj_level1).children(.obj_level2).attr( id,
  Bob );

  Originally I was using:

  $(#obj  .obj_level1  .obj_level2).attr( id, Bob );

  And that worked ok, but I needed the object in a variable as I and
  using it repeatedly and didn't want to dereference it every time I use
  it, for speed's sake.

  Any thoughts as to the correct syntax to do this?

  Thanks,
  ml


[jQuery] Re: Trying to set the id of a 2nd level div and failing

2008-01-15 Thread Wizzud

Use find()?
The children() function (should) return unique immediate children
which won't get you your second level divs in a single call from the
#obj level, no matter what selector you use.

eg...
var obj = $(#obj);
obj.find(.obj_level1.obj_level2).attr( id, Bob );


On Jan 15, 6:03 am, Mark Lacas [EMAIL PROTECTED] wrote:
 I'm trying to set the id of a 2nd level obj selected by class and it
 doesn't seem to work as I thought it would.

 Unfortunately all of the level one objects get the id assignment, not
 the level two object.

 Here it is before I do the operation:

 div id=obj
 div class=obj_level1
 div class=obj_level2/div
 /div
 div class=obj_level1.1/div
 /div

 Then I do this:

 var obj = $(#obj);
 //bunch of code
 obj.children(.obj_level1  .obj_level2).attr( id, Bob );

 It ends up like this:

 div id=obj
 div id=Bob class=obj_level1
 div class=obj_level2/div
 /div
 div id=Bob class=obj_level1.1/div
 /div

 Note the two divs with the same id. . .

 Do I have to use:

 obj.children(.obj_level1).children(.obj_level2).attr( id,
 Bob );

 Originally I was using:

 $(#obj  .obj_level1  .obj_level2).attr( id, Bob );

 And that worked ok, but I needed the object in a variable as I and
 using it repeatedly and didn't want to dereference it every time I use
 it, for speed's sake.

 Any thoughts as to the correct syntax to do this?

 Thanks,
 ml