Removing, Replacing and Moving Elements in jQuery

  You are currently not logged in. You can view the forums, but cannot post messages. Log In | Register

08-Jun-10 00:00
This is a forum topic for discussing the article "Removing, Replacing and Moving Elements in jQuery":

http://www.elated.com/articles/jquery-removing-replacing-moving-elements/

Learn how to use jQuery to easily remove elements from the page, replace elements, and move elements around.
28-Feb-11 01:56
Help Me.....?


<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Sign in</a>or<a href="#">New User</a>
</li>
</ul>


How to remove the word 'or' in the second li?
or How to achieve the following?

<li><a href="#">Sign in</a>
<span>or</span>
<a href="#">New User</a>


[Edited by gokul357 on 28-Feb-11 02:01]
02-Mar-11 01:59
@gokul357: This topic is for discussing the article. Please post your question in a new topic:

http://www.elated.com/forums/authoring-and-programming/topic/new/

--
Matt Doyle, Elated
3rd Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/
07-Apr-11 19:04
Working on the moving principal, using prepend instead of append, I'm wondering how to keep cloning from happening. Is that an easy thing to implement?

For example, on a page with multiple DIV elements of the same ID/class, how do I tell a child element to move to another child but only relative to its parent? Right now I have:


$('.entry-body').prepend($('.entry-comments'));


But on a page with 4 instances of .entry-body, and the same number of .entry-comments, the above prepend code ends up populating 4 times in each .entry-body instance.

You mentioned that "jQuery first removes the content from its old parent, then clones the content as many times as necessary and adds a clone to each parent element" and that's exactly what I'd prefer not to happen. Thoughts?
11-Apr-11 00:27
@brianna: You need to find a way to specifically select the single .entry-body element you're interested in, rather than selecting all 4 elements with the .entry-body class.

I can't give exact information without seeing your page. However I think you'll find jQuery's parent() method useful:

http://api.jquery.com/parent/

Cheers,
Matt

--
Matt Doyle, Elated
3rd Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/
28-Feb-12 13:03
Thank you very much!

--
http://php-junior.ru/

 
New posts
Old posts

Follow Elated