Forms

From rbachwiki
Revision as of 18:12, 26 December 2016 by Bacchas (talk | contribs)
Jump to navigation Jump to search

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');

Set the property

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

Set multiple properties using a object

$('#id').prop({'checked': true,
'disabled':false});

Radio Buttons

Return the value of which button is selected

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



Back To Top< — >Category< — > Home