We help IT Professionals succeed at work.
Get Started

remove current contents of div and then add new content using DOM

brad0525 asked
Last Modified: 2013-11-18
I am using the code below to move items to the "second" div..It works fine to move them. I know need it to move the new item to the "second" div but remove the current item too. Any help would be greatly appreciated..thanks
<script language="javascript">
	$(document).ready(function() {
		$("a").click(function() {
				id: $(this).attr("value"),
				style: "border:none;font-weight:bold;background-color:white;",
				value : "I'm "+$(this).attr("value")

First section :<br />
<div id="first">
    <div><input type="hidden" id="chip1"  value="1" >Chip1&nbsp;<a href="#" value="chip1">move</a><br /></div>
    <div><input type="hidden" id="chip2"   value="1" >Chip2&nbsp;<a href="#" value="chip2">move</a><br /></div>
    <div><input type="hidden" id="chip3"   value="1" >Chip3&nbsp;<a href="#" value="chip3">move</a><br /></div>
    <div><input type="hidden" id="chip4"   value="1" >Chip4&nbsp;<a href="#" value="chip4">move</a><br /></div>
Second section :<br />
<div id="second">

Open in new window

Watch Question
Senior Software Analyst
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE