Question

Can anyone help me with a JQuery syntax issue?

This test works fine:

if ( $('input[name="'+ Field +'"]').is((':radio')) ) { do something }

But, I would like to test if the input is NOT radio and, honestly, I'm struggling.

Sorry for my poor English.

Best regards

Was it helpful?

Solution

if ( $('input[name="'+ Field +'"]').is(':not(:radio)')) { do something }

OTHER TIPS

Just negate the condition :

if ( ! $('input[name="'+ Field +'"]').is(':radio') ) //check the bang at the start

You could also use :not but it's slower :

if ( $('input[name="'+ Field +'"]').is(':not(:radio)') ) 

Just seems easier without jQuery

if ( document.getElementsByName(Field)[0].type != 'radio' ) {

}

Both methods are good

if ( ! $('input[name="'+ Field +'"]').is(':radio') ) { do something }

and

if ( $('input[name="'+ Field +'"]').is(':not(:radio)')) ) { do something }

Didn't try the javascript option, suppose it works too ;)

You save my day thank you all for your very quick answers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top