简体   繁体   中英

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');    
}

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');
}

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');

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM