简体   繁体   中英

how to select 2 div from 10 div jquery?

I want to select 2 div from many div when click them.

 <div id="1">one</div> <div id="2">two</div> <div id="3">three</div> <div id="4">four</div>

what it does is it makes a loop for 1 through 3 and selects every element with the id of 1-2 and changes their text to selected

for (let i = 1; i < 3; i++) {
    document.getElementById(`${i}`).innerText = "Selected"}

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