Jitendra Vyas
Jitendra Vyas

Reputation: 152657

How to change original html code in runtime via jquery?

<blockquote><p>We prefer questions that can be answered, not just discussed. Provide details. Write clearly and simply.If your question is about this website, ask it on meta instead.</p></blockquote>.

I want to change above code to this.

    <blockquote>
    <div class="quote_start"><div></div></div><div class="quote_end"><div></div></div>
    <p>We prefer questions that can be answered, not just discussed.
Provide details. Write clearly and simply.If your question is about this website, ask it on meta instead.</p>
    </blockquote>

Upvotes: 0

Views: 515

Answers (2)

Pharabus
Pharabus

Reputation: 6062

is this the only blockquote? if so you could use prepend/

$("blockquote").prepend("<div class='quote_start'><div></div></div><div class='quote_end'><div></div></div>");

Otherwise you would need to find someway to identify the blockquote in question before doing the prepend.

Upvotes: 1

RHicke
RHicke

Reputation: 3604

Use the prepend method

$('blockquote').prepend('<div class="quote_start"><div></div></div><div class="quote_end"><div></div></div>');

That will place the text as the first child element of the selected object

Upvotes: 3

Related Questions