jquery - Cannot get html() for parent span -
this question has answer here:
- get selected element's outer html 26 answers
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
Post a Comment