jQuery.contains method is a general utility method that returns a boolean object if DOM element in the second argument is within the DOM element of the first argument.
The syntax is as follows:- jQuery.contains( container , contained ).
I am using jQuery.contains( outer, inner ) in the example below:
$(function(){
$('#btnEg').one('click', function(){
$('#div'Eg).append('Is there some content? : ' +
jQuery.contains( document.documentElement, document.body ) + '
');
$('#divEg').append('Is there some content? : ' +
jQuery.contains( document.body, document.documentElement ) + '
');
});
});
In the example above, on pressing the button the first time,we check to see if document.documentElement (the tag) contains document.body (the tag),which returns true. Then we check to see if document.body (the tag) contains document.documentElement (the tag),which returns false.
0 Comment(s)