简体   繁体   中英

how to select elements by name with serial

Is there any way to select elements with wildcard?

Markup

<input type="text" name="variable_ebay_ean[0]" class="" value="505517254641">
<input type="text" name="variable_ebay_ean[1]" class="" value="505517254642">
<input type="text" name="variable_ebay_ean[2]" class="" value="505517254643">

and JavaScript code to select elements

let o= document.querySelectorAll("[name='variable_ebay_ean[(*)]']");

You can reach it using the " Starts with " selector.

let o= document.querySelectorAll("[name^='variable_ebay_ean']");

 let o = document.querySelectorAll("[name^='variable_ebay_ean']"); console.log(o);
 <input type="text" name="variable_ebay_ean[0]" class="" value="505517254641"> <input type="text" name="variable_ebay_ean[1]" class="" value="505517254642"> <input type="text" name="variable_ebay_ean[2]" class="" value="505517254643">

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