as far i know how to get innerHTML but now i want to get only specified tags. let say i only want those line of tags who contains test-class.
<div id="parent">
<div class="test-class"> some texts </div>
<div class="class_1"> some text </div>
</div>
$(functio() {
$('#parent').html();
});
But my expected result should be <div class="test-class"> please give me any idea.
some texts
</div>.
Thanks in advance. Edit @Js
<html> <head>
/* css & js file attached */
<script type="text/javascript">
jQuery.fn.outerHTML = function(s) {
return (s) ? this.before(s).remove() :
jQuery("<div>").append(this.eq(0).clone()).html();
}
$(function() {
var outerHTML = $('#parent').find('.test-class').outerHTML();
alert(outerHTML);
});
</script>
</head> <body>
/* the same html code as above */
</body> </html>
1 Answer