Home > Article > Web Front-end > jQuery gets select selected value and clears selected status
I really can’t bear the pain of not being able to use jQuery in the background. It took me a while to get the value of the select drop-down list, but it didn’t end. It also took me half an hour to restore the selected state.
Remember the province here first, you will forget it later.
Get the lang attribute value in the select drop-down list in jQuery:
<span style="font-size:14px;"> var provinceSearch = $("#loc_province_search").find("option:selected").attr("lang");//获取下拉列表选中值 var citySearch = $("#loc_city_search").find("option:selected").attr("lang");//获取下拉列表选中值 var townSearch = $("#loc_town_search").find("option:selected").attr("lang");//获取下拉列表选中值 var linkMan = $('.customer_input_contact').val();//获取输入框内的值 var customerLevel = $(".txt_classification").attr("lang");//获取下拉列表的lang属性值 var customerTrade = $(".txt_industry").attr("lang");//获取下拉列表的lang属性值 var customerClass = $(".txt_segmentation").attr("lang");//获取下拉列表的lang属性值 var busi_statusType = $(".customer_busi_status2").attr("lang");//获取下拉列表的lang属性值</span>
Clear the selected state of the select drop-down list:
<span style="font-size:14px;"> customer_busi_div.find('input').val('');//清除输入框内容 $("#loc_province_search").attr("lang",'0');//将下拉列表属性lang置为初始值 $("#loc_city_search").attr("lang",'0');//将下拉列表属性lang置为初始值 $("#loc_town_search").attr("lang",'0');//将下拉列表属性lang置为初始值 $(".txt_classification").attr("lang",'0');//将下拉列表属性lang置为初始值 $(".txt_industry").attr("lang",'0');//将下拉列表属性lang置为初始值 $(".txt_segmentation").attr("lang",'0');//将下拉列表属性lang置为初始值 $(".customer_busi_status2").attr("lang",'0');//将下拉列表属性lang置为初始值 $("#searchkey").attr("lang",'0');//将下拉列表属性lang置为初始值</span>
The above is the jQuery introduced by the editor Get the selected value and clear the selected status. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank you all for your support of the PHP Chinese website!
For more jQuery related articles on getting the select value and clearing the selected status, please pay attention to the PHP Chinese website!