/    Sign up×
Community /Pin to ProfileBookmark

replace one div with another (jquery)

Hi guys!

I’m trying to do a ‘simple’ replace from one div to another. I’ve searched and found some jquery scripts but can’t seem to get it to work…I probably just have the syntax wrong…could somebody please help?

The code I have is below. I just want to replace the div.address with div.addressEdit when a user clicks the ‘edit’ link.

Thanks so much!

Len

<script>
$(“a.address”).click(function () {
$(“div.address”).replaceWith( $(“.addressEdit”) );
});
</script>

<div class=”address fLeft” style=”margin-right:20px;”>
<p><input type=”radio” value=”” style=”margin-right:10px;” name=”shipto”> Ship to this Address</p>

<blockquote>
<p><strong>Work</strong><br />
UniFirst Corporation<br />
Patrick O’Leary<br />
68 Jonspin Rd.<br />
Wilmington, MA 01887<br />
(978) 658-8888<br />
<a class=”small address” href=””>edit</a> | <a class=”small” href=””>remove</a></p>
</blockquote>
</div>

<div style=”display:none;”>
<div class=”fLeft addressEdit” style=”margin-right:20px;”>
<p><input type=”radio” value=”” style=”margin-right:10px;” name=”shipto”> Ship to this Address</p>

<blockquote>
<input class=”address” value=”Work” /><br />
<input class=”address” value=”UniFirst Corporation” /><br />
<input class=”address” value=”Patrick O’Leary” /><br />
<input class=”address” value=”68 Jonspin Rd.” /><br />
<input class=”address” value=”Wilmington, MA 01887″ /><br />
<input class=”address” value=”(978) 658-8888″ /><br />
<a class=”small” href=”#” onClick=”window.location.reload();return false;”>cancel</a> | <a class=”small” href=””>remove</a></p>
</blockquote>
</div>
</div>

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @lprintz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...