Monday, February 12, 2018

JQuery body append html


I wanted to append the html to body like below and the html control will be accessed in a JavaScript function.

$("body").append('<div id="vedioControl">VEDIO CONTROL</div >');

When I accessed the html control in a JavaScript function, I got an operation aborted error.
I have double checked the above statement, nothing is wrong.

Later I found that that, html will not be added to body unless the DOM is loaded.
To make sure the DOM is loaded, added the statement within the .ready function.

$(document).ready(function()
{     
      $("body").append('<div id=" vedioControl "> VEDIO CONTROL</div>');
});

No comments:

Post a Comment