Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Using a General utility method jQuery.contains().

    • 0
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 103
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: