Taufik Pirjade
Taufik Pirjade

Reputation: 440

how to insert multi line string html using jquery?

I have following structure and i want to append it to a <div> but it's showing a compile time error.

$('#row1').html("<div class="4u 12u(mobile)">
            <section>
                    <a href="#" class="image featured"><img src="images/kokan.jpg" alt="" /></a>
                    <header >
                        <h3>result[i]</h3>
                        <p></p>
                    </header>
                </section>
            </div>");

Upvotes: 3

Views: 1957

Answers (1)

void
void

Reputation: 36703

$('#row1').html('<div class="4u 12u(mobile)">'
            +'<section>'
                    +'<a href="#" class="image featured"><img src="images/kokan.jpg" alt="" /></a>'
                    +'<header >'
                        +'<h3>'+result[i]+'</h3>'
                        +'<p></p>'
                    +'</header>'
                +'</section>'
            +'</div>');

You need to build a proper string, by concatenating parts. "<div class="4u this part was also breaking, you should use combinations of " '' ".

Upvotes: 4

Related Questions