How to add “selected” in option attribute using Javascript or jQuery?

后端 未结 6 905
猫巷女王i
猫巷女王i 2021-02-09 02:16

Below is code for select option and generate using php from database and i try to add selected=\"selected\" to value=\"4\" using jQuery or any javascri

6条回答
  •  野性不改
    2021-02-09 02:42

    localStorage.getItem("Select1") will return Malaysia and $(e).val() will return 1,2...5 in each loop. So your condition will never be true. Instead use

    
    

提交回复
热议问题