for example:
<li class="list" id="first-list"></li>
var li = document.getElementById("first-list");
matchSelector(li, "li.list"); // this should return true
now my solution could be described as:
function matchSelector(element, selector){
var all_matched_elements = $(selector);
return element in all_matched_elements
}
but obviously this includes some unnecessary work.
is there a better solution?
You can use jQuery is method.
Something like:
Working example: http://jsfiddle.net/NqwxQ/