Cannot set jquery dialog.InnerHtml (some-content) without refreshing page

In my JS file, I am trying to set the contents in the dialog that appears. In firebug, I saw that the dialog opens and it freezes even after I installed its contents $(dialog).InnerHtml. But it works when I refresh the page.

Any specific reason for this behavior?

+5
source share
2 answers

You cannot install .innerHTMLdirectly from a jQuery object. Instead, you need to install $.html().

// jQuery doesn't have an innerHTML property, so this is wrong
$("#dialog").innerHTML = "This is the wrong way";

// jQuery has an html() method that sets the html within your dialog
$("#dialog").html( "And this is the correct way" );

, jQuery, , . .innerHTML DOM, jQuery. jQuery , $.html(), - .innerHTML.

+12

:

javascript:

document.getElementById('dialog').innerHTML = 'something';

JQuery:

$("#dialog").html('something');
+1

All Articles