Baji
Baji

Reputation: 131

How to get the html content loaded with jquery load function

I have created dynamic div element as shown below

var newDiv1 = $(document.createElement('div')); 
newDiv1.attr('id','nedi');
newDiv1.attr('style','position:absolute;top:10;right:15;');

I am trying to load html content with the following line of code but ended up in vain!

$('#newDiv1').load('new_one_2.html');

my folder structure as shown in the image attached. Please help me to load html content with jquery load

Please see attached image

Upvotes: 0

Views: 59

Answers (1)

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167172

You have given a different ID. Use:

$('#nedi').load('new_one_2.html');

Variable name is different from id. Or you should use something like:

$.get("new_one_2.html", function (res) {
  newDiv1.html(res);
});

Upvotes: 1

Related Questions