[jQuery] Variable and additional selectors

2009-12-11 Thread Adomatic
I'm just starting to play with jQuery and, like everyone before me,
I'm amazed by it's power.

In short, my question is about cloning an object, manipulating it in
multiple steps and and then appending it to a list.

I have an li on my page containing several divs (a user avatar and a
couple lines of text).  I wanted to clone that item (rather than
building a whole lot of HTML in strings), change the avatar URL and
some of the text then append the new object to a list.

I see that I can do this:
  var entry = $(#userlist  li).clone();
  $(entry).appendTo(#userlist);

However, entry has several divs that I'd like to manipulate between
cloning and appending.  Is there a way to use selectors to get those
divs, manipulate them within entry?

Entry is a jQuery so I thought I could do something like entry
(.avatar)... or something but that's not right.

Your guidance would be appreciated!


Re: [jQuery] Variable and additional selectors

2009-12-11 Thread John Arrowwood
var entry = $('#userlist  li).clone();
$('stuff',entry)...  | $(entry).find('stuff')...
$(entry).appendTo('#userlist')

On Fri, Dec 11, 2009 at 1:46 PM, Adomatic adobi...@gmail.com wrote:

 I'm just starting to play with jQuery and, like everyone before me,
 I'm amazed by it's power.

 In short, my question is about cloning an object, manipulating it in
 multiple steps and and then appending it to a list.

 I have an li on my page containing several divs (a user avatar and a
 couple lines of text).  I wanted to clone that item (rather than
 building a whole lot of HTML in strings), change the avatar URL and
 some of the text then append the new object to a list.

 I see that I can do this:
  var entry = $(#userlist  li).clone();
  $(entry).appendTo(#userlist);

 However, entry has several divs that I'd like to manipulate between
 cloning and appending.  Is there a way to use selectors to get those
 divs, manipulate them within entry?

 Entry is a jQuery so I thought I could do something like entry
 (.avatar)... or something but that's not right.

 Your guidance would be appreciated!




-- 
John Arrowwood
John (at) Irie (dash) Inc (dot) com
John (at) Arrowwood Photography (dot) com
John (at) Hanlons Razor (dot) com
--
http://arrowwood.blogspot.com
Pablo Picassohttp://www.brainyquote.com/quotes/authors/p/pablo_picasso.html
- Computers are useless. They can only give you answers.