user2322509
user2322509

Reputation: 277

Jquery append content to div

I load a content to <div id="wrapper"></div> via jquery.

$('#wrapper').html(data);

When the content inserted into wrapper, there is another div with id="video1".

How can I append something to that id="video1"

Upvotes: 6

Views: 40029

Answers (6)

Aleksandar Knezevic
Aleksandar Knezevic

Reputation: 1

Apparently, it is not possible to add something dynamically, e.g. content, to something that is considered static (as to my knowledge, could be wrong).

So, either you write it manually or you make some sort of automatisation...meaning JS for example.

So, the answer would be no, to all those questions/question.

Regards

Upvotes: -2

ipradhansk
ipradhansk

Reputation: 352

This would definitely work:

$('#wrapper').html(
    $('<div>').attr({'id':'video1'})
);

Upvotes: 0

bipen
bipen

Reputation: 36551

try this,

$('#wrapper').find('#video1').append('thingsYouWant');

OR

$('#wrapper').html(data);
$('#video1').append('thingsYouWant');

you can directly use id selector to get the element after the element is added to the DOM

Upvotes: 0

Anoop
Anoop

Reputation: 23208

$('#wrapper').html(data);
$('#video1').html("new data");

Upvotes: 0

palaѕн
palaѕн

Reputation: 73966

$('#video1').append('<p>Test</p>');

For demo, I have appended p here.

Upvotes: 16

Benjamin Gruenbaum
Benjamin Gruenbaum

Reputation: 276536

Here is a working fiddle

You can find the div by its ID in 'wrapper' after you insert it using .find

$('#wrapper').html(data).find("#video1").append(<Your Data Here>);

Upvotes: 3

Related Questions