Difference between revisions of "Forms"

From rbachwiki
Jump to navigation Jump to search
(Created page with "== Form Events== <pre> $(function() { 'use strict'; $('#name2').on('click', nameClick); function nameClick() { $(this).css('background-color', 'blue');...")
 
Line 15: Line 15:
});
});
</pre>
</pre>
== Getting values from form==
$('#id').val()
==Get Attributes==
$('a:first').attr('href')
== Set Attributes ==
$('a:first').attr('href','contact.html')
== CheckBoxes ==
'''Will Return True or False'''
$('#id').prop('checked');
==Radio Buttons==
'''Return the value of which button is selected'''
$('[name=news]:checked').val();
----
[[#top|Back To Top]]<  —  >[[JQuery|Category]]<  —  >[[Main_Page| Home]]
[[#top|Back To Top]]<  —  >[[JQuery|Category]]<  —  >[[Main_Page| Home]]

Revision as of 18:07, 26 December 2016

Form Events

$(function() {
    'use strict';
    $('#name2').on('click', nameClick);

    function nameClick() {
        $(this).css('background-color', 'blue');
    }

    $('#frmContact').on('submit', function(event) {
        // pevents the default submit action from happening
        event.preventDefault();
    });
});

Getting values from form

$('#id').val()

Get Attributes

$('a:first').attr('href')

Set Attributes

$('a:first').attr('href','contact.html')

CheckBoxes

Will Return True or False

$('#id').prop('checked');

Radio Buttons

Return the value of which button is selected

$('[name=news]:checked').val();

Back To Top< — >Category< — > Home