I have the following html string:
<html>
<head>
</head>
<body>
<table>
<tbody>
<th>
<tr>
<img src=""/>
</tr>
</th>
</tbody>
</table>
</body>
</html>
Is there a way to get only the img
element?
So in this case I want a string like this <img src=""/>
.
More specific example:
$wikiDOM = $("<document>"+ wikiHTML+ "</document>");
var infobox = $wikiDOM.find('.infobox').html();
if(infobox != 'undefined' && infobox !== ""){
var img = infobox.filter( 'img' );
console.log( img[0].outerHTML );
}
where wikiHTML is the request i make to wikipedia api in json format for several searchterms.
Edit:
return from img and infobox:
image:[object Object]
infobox[object Object]
image:[object Object]
infobox[object Object]
image:[object Object]
infobox[object Object]
image:[object Object]
infobox[object Object]
image:[object Object]
infobox[object Object]
image:[object Object]
infobox[object Object]
image:[object Object]
infobox[object Object]
image:[object Object]
infobox[object Object]