Mike
Mike

Reputation: 1863

Adding block via jQuery

We have some block. Ex:

<div class="block"></div>

and we want to add tag inside it, so, at the end it would seems like this:

<div class="block"><i></i></div>

How to do it with jQuery?

Upvotes: 1

Views: 110

Answers (3)

UK-AL
UK-AL

Reputation: 548

Quick way is $('.block').append('<i></i>'); Although this add would add it all div with block classes.

You might need a unique id for a invidual div which would then be.

$('#block').append('');

Upvotes: 1

Mark Bell
Mark Bell

Reputation: 29785

$('.block').append('<i></i>');

Upvotes: 1

peirix
peirix

Reputation: 37771

Easy (:

$(".block").append("<i></i>");

or

$(".block").html("<i></i>");

or any of the dozens of DOM manipulators offered by jQuery

Upvotes: 2

Related Questions