I'm trying to get html code of a child element using following code :
HTML
<div id="cont">
<img src="http://fakeimg.pl/230x153/555/FFF/?text=1" alt="">
</div>
JQUERY
$(function() {
console.log($("#cont").find("img").html());
});
I would like to have <img src="http://fakeimg.pl/230x153/555/FFF/?text=1" alt="">
in my console
But Its returning nothing. I dont know whats wrong. I'm pretty sure I'm making some silly mistake.
Thanks.
Link to jsBin : http://jsbin.com/urahos/1/edit
EDIT
Correct Answer
I dont know someone just posted the right answer and removed it.
Following is what I was looking for :
$(function(){
$("#cont").find("img")[0].outerHTML;
});