The case : should select object
example:
function getDomPart(text,htmlTag){
return $(text).closest(htmlTag).get(0);
}
var text1='<object>some text + html elements </object>';
var text2='<div><object>some text + html elements </object></div>';
alert(getDomPart(text1,'object'));
alert(getDomPart(text2,'object'));
the result should be: some text + html elements
but its not.
please tell me what should be fixed.
Edit:
please see my answer with short solution.
The solution that i get idea about : add wrapper element then can be used only find :
Demo:
http://jsfiddle.net/EaZrs/5/