Skip to content
This repository has been archived by the owner on Sep 13, 2019. It is now read-only.

[jQuery] A simple plugin used for getting any given input element's type.

License

Notifications You must be signed in to change notification settings

tommcfarlin/jquery-get-input-type

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery getInputType

This plugin is an extremely simple jQuery plugin used to determine what type of input element on which an event is being raised.

This is compatible with:

  • Text elements
  • Textareas
  • Checkboxes
  • Radio Bioxes
  • Select options
  • ...and more

I created this plugin because I found myself doing work with groups of input elements and needed an easy way to determine which input element was raising an event.

Installation

  1. Download the plugin from the master branch.
  2. Setup the plugin in the head element of your HTML document.
  3. Note that the plugin should be added after jQuery and before your own JavaScript.

Example

Installation

<script type="text/javascript" src="js/jquery.get-input-type.min.js"></script>

Usage

Given a set of input elements:

$('.input-elements, .select-elements').on( 'change', function(evt) {

   if ( 'select' === $(this).getInputType() ) {

       // You're working with a select element

   } elseif ( 'checkbox' == $(this).getInputType() ) {

       // You're working with a checkbox element

   } else {

       // Do something else

   }

});

Contact

Licensing

About

[jQuery] A simple plugin used for getting any given input element's type.

Resources

License

Stars

Watchers

Forks

Packages

No packages published