H5 page, JQ operation select syntax

<select  class=".j_option">   //这里$option 选中的是整个select

$option.val(); //Get selected value of select
$option.find('option:selected').text(); //Get selected text of select
$option.text() //Get all text of select
$ option.val(4) //Set select to select the option with val as 4

//Monitor select
$option.change(()=>{ not only monitor it, but also use this method to monitor many elements, such as text })

//Append an Option to Select (the last position)
$option.append("Option 5");

//Insert an Option for Select (first position)
$option.prepend("Please select");

Guess you like

Origin blog.csdn.net/weixin_45629623/article/details/113700962