Saturday, 15 January 2011

How to get selector type using javascript or jquery for use in switch statement -



How to get selector type using javascript or jquery for use in switch statement -

i have next code find type of selector , respond appropriately. ugly best have been able come far distinguish between input types checkbox, radio, text, , select drop downwards list. hoping there way switch statement.

if ($(selector).is(':checkbox')){ //do }else{ if (selector.indexof("radio") >= 0){ //do }else{ if ($(selector).is('input') || $(selector).is('select')) { //do } } }

one thing bring $(selector).is('input') way figured out how grab input type="text" grab checkboxes had set @ bottom.

i utilize $().attr().

if($(selector).attr('type') == 'text')

javascript jquery jquery-selectors css-selectors

No comments:

Post a Comment