How Do I Append Both An Element And Text To A Div In Jquery?
I'm using jQuery and trying to append both an element and some text to an existing div element. However, when I try this $('').appendTo(gMenuItemInnerD
Solution 1:
var gMenuItemInnerDiv = $('#something');
var name = "<b>Yay</b>";
$('<img src="/img.png" />').appendTo(gMenuItemInnerDiv);
gMenuItemInnerDiv.append( document.createTextNode(name) );
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divid="something"></div>
Post a Comment for "How Do I Append Both An Element And Text To A Div In Jquery?"