jquery - Cannot get html() for parent span -


this question has answer here:

i trying simple thing maybe missing something:

var span = $(document.createelement("span")); // create span var img = new image(); // create image , set source img.src = config.graph_url + member.facebook_id + "/picture?width=24&height=24"; span.append($(img)); // add image inside span 

how can html <span><img src="_source_"/></span>? span.html() outputs <img src="_source_"/>.

it's working fine. html() method sets or returns content (innerhtml) of selected elements

in html document, .html() can used contents of element. if selector expression matches more 1 element, first match have html content returned.

so can use .outerhtml this

$('span')[0].outerhtml; 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -