0

Here is the existing HTML

<div id="options_12" class="pagebody">
    <div id="contentframe">
        <div id="hsubmenu"></div>
        <div id="vsubmenu"></div>
        <div id="withmenus" class="withleft"></div>
        <div class="nflteampage"></div>
    </div>
</div>
<div class="pagefooter"></div>

I am unable to edit any of the HTML but i'm provided the use of jQuery , i want to remove the .pagefooter and replace it with .nflteampage

I tried this will no success

$( ".pagefooter" ).replaceWith( ".nflteampage" );
2
  • 7
    $(".pagefooter").replaceWith($(".nflteampage")); Commented Sep 1, 2014 at 13:36
  • To be fair, typing in a quick one-liner takes considerably less time than an answer which also tries to add to the code-snippet why it actually would work (that being said, I actually saw your comment after I've already submitted my answer). Also, the placeholder right in this box says the comments should serve for acquiring more info from the OP about the question and answering (be it any length, and regardless the question's complexity) should be avoided. The ori. question contained some amount of proof of attempts done and not just a "how do I this"-type - I'd say the question was alright. Commented Sep 1, 2014 at 13:52

3 Answers 3

3

As your replaceWith() currently stands, you're telling it to replace your .pagefooter element with a string literal, and not a selected element.

You'll have to go with:

$(".pagefooter").replaceWith($(".nflteampage"));

With the dollar sign at the beginning, you're telling jQuery to go and fetch that element, then the rest is as you would expect.

Sign up to request clarification or add additional context in comments.

Comments

0

You need to pass html code in the replace with, so you need to target the class and gets its html.

$( ".pagefooter" ).replaceWith( $(".nflteampage").html() );

working example here http://jsfiddle.net/dcfn4epn/1/

Comments

-1

Try:

$('.pagefooter').remove();

to remove the footer and

$('.nflteampage').insertAfter("#options_12");

to insert the new stuff after your options-div.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.