Reputation: 409
I have a form and I want to disable all the Elements that do not match a given ID using jquery
here is the basic logic I'm trying to achieve
for (AllElementsInthisForm){
if(formElementID != specificid)
{
disable
}
}
I hope that makes sense. Any ideas?
Upvotes: 1
Views: 183
Reputation: 84140
There is a :not selector.
$('#FORMID input:not(#IDNAME)').attr('disabled', 'disabled');
Or an alternative sytax which is suitable for more complex conditions:
$('#FORMID input:not([id=IDNAME])').attr('disabled', 'disabled');
Upvotes: 4
Reputation: 392
A class would make more sense in your case.
<div class="disableThis" />
<a class="disableThis />
<script>
$('.disableThis').attr('disabled', 'disabled');
</script>
Upvotes: 0