JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/ui-lightness/jquery-ui.css">
JavaScript
var string = "sdsds<div>sdd<a href='http://google.com/image1.gif'>image1</a> sd</div>sdsdsdssssssssssssssssssssssssssssssssssss <p> <a href='some/href'></a> sdsdsdsds </p>sdsds<div>sdd<img src='http://google.com/image1.gif' alt='car for family' /> sd</div>";
var $container = $('<div/>').html(string);
var result = [];
$container.find('a,img').each(function() {
if(this.tagName.toUpperCase() == 'A') {
if($.trim( this.innerHTML ) != '') {
result.push([this.tagName,this.innerHTML,this.href]);
}
} else {
result.push([this.tagName,this.src,this.alt]);
}
});
alert(result);