In my JS file, I am trying to set the content to a poped up dialog. In firebug, I saw the dialog opens and it hangs even after I set the content of it by $(dialog).InnerHtml
.
But this works when I refresh the page.
Any particular reason for this behavior?
You cannot set .innerHTML
directly off the jQuery object. You need to set $.html()
instead.
// 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" );
Keep in mind that when you're dealing with jQuery, you're dealing with an object, and not an element. Attributes like .innerHTML
exist on elements within the DOM, but not within the jQuery object. jQuery provides methods like $.html()
so that you don't have to ever touch .innerHTML
.
This is the way to do:
In javascript:
document.getElementById('dialog').innerHTML = 'something';
In Jquery :
$("#dialog").html('something');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With