toto
toto

Reputation: 1

How to select using multiple attribute selectors?

I am trying to disable multiple fields in a checkbox survey at the same time. Is it possible to select by multiple classes on same the div? I tried below but its not working. The code works with one class.

function surveyInit(){
  $("div[class*='addressLine1', class*='addressLine2'] input"  ).attr('disabled', 'disabled');    
}

Upvotes: 0

Views: 88

Answers (2)

ahmet dundar
ahmet dundar

Reputation: 92

you need comma as seperator and you can youse dot to select class instead of attribute selector

function surveyInit(){
 $("div.addressLine1 input,div.addressLine2 input"  ).attr('disabled', 'disabled');

}

Upvotes: -2

Barmar
Barmar

Reputation: 780798

You need to use multiple selectors separated by commas, not put the commas inside the attribute selector.

function surveyInit(){
    $("div[class*='addressLine1'] input, div[class*='addressLine2'] input").attr('disabled', 'disabled');
}

Upvotes: 6

Related Questions