JQuery

    Jquery Autoscroll on hyperlinks

    Go to Test Div
    $('a.derivate').click(function(){
        $('html, body').animate({
            scrollTop: $( $(this).attr('href') ).offset().top
        }, 500);
        return false;
    });
    It will scroll here

    How to play youtube video on click action jquery

    This can be done simply by changing the source in the iframe tag with autoplay enabled:
    $('#clicked_item').click(function() {
        $("#wrapper_div_id iframe").attr('src', $("#wrapper_div_id iframe", parent).attr('src') + '?autoplay=1');
    });


    #clicked_item : ID of the item who click plays video
    #wrapper_div_id : ID of the div contaning video iframe or you can use iframe id directly

    How to decrease padding slowly in jquery?

    You can use animate to decrease padding slowly by specifying slow in animate function.
     
    $('#link1').click(function() {
      $("#block").animate({
          'padding-top' : 0,
          'padding-right' : 0,
          'padding-bottom' : 0,
          'padding-left' : 0,
        }, "slow");
    });

    How to hide/close div/form elements when clicking outside it

    var mouse_in = false; $('#new_request').hover(function(){ mouse_in=true; }, function(){ mouse_in=false; }); $("body").mouseup(function(){ if(!

    How to validate multiple radio buttons jQuery

    to validation multiple radio buttons using jquery use following code

    HTML Code

    How to count checked checkboxes using jquery

    To count checked checkboxes using jquer use following code for example
    Jquery code to count checked elementson click

    How to validate email using jquery

    To validate email using jquery you can use following script $(document).ready(function() { $('#comment-submit').click(function() { var emailaddress = $('#comment-email').val(); var emailexp = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; if (emailaddress == '') { alert('Please enter email.'); $('#comment-email').focus(); return false; } else if(!emailexp.test(emailaddress)) { alert('Please enter valid email address.'); $('#comment-email').focus();

    How to check if an element exists using jquery

    There are many ways to check if an element exists or not using jquery:
    if ($('#elementid').length > 0) {
       //your jquery code here
    }

    or simply
    if ($('#elementid').length) {
       //your jquery code here
    }


    Also

    if ($('#elementid').size()) {
       //your jquery code here
    }

    How to check if checkbox is checked using jquery

    You can do this using jQuery in following way:
    // First method
    $('#edit-country-id').is(':checked');

    // where edit-country-id is id of element need to be checked

    // Second method
    $('#countryinfo').attr('checked');

    // where countryinfo is id of element need to be checked

    How to show hide div on clicking a link?

    You can do this by using jquery toggle function Here is the Html
    <a href="#" id="showmenu">Click Here</a>
    <div id="content_div" style="display:none;position:absolute;">
    <ul>
      <li>Link 1</li>
      <li>Link 2</li>
      <li>Link 3</li>
      <li>Link 4</li>
      <li>Link 5</li>
      <li>Link 6</li>
      <li>Link 7</li>
      <li>Link 8</li>
    </div>
    Here is the js code:
    <script language="javascript">
    $('#showmenu').click(function() {
      $('#content_div').toggle('slow');
    });
    </script>
    Note: Please include Jquery.js