Home  >  Article  >  Web Front-end  >  jQuery gets select selected value and clears selected status

jQuery gets select selected value and clears selected status

高洛峰
高洛峰Original
2016-12-28 09:53:104523browse

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 = $(&#39;.customer_input_contact&#39;).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(&#39;input&#39;).val(&#39;&#39;);//清除输入框内容 
      $("#loc_province_search").attr("lang",&#39;0&#39;);//将下拉列表属性lang置为初始值 
      $("#loc_city_search").attr("lang",&#39;0&#39;);//将下拉列表属性lang置为初始值 
      $("#loc_town_search").attr("lang",&#39;0&#39;);//将下拉列表属性lang置为初始值 
      $(".txt_classification").attr("lang",&#39;0&#39;);//将下拉列表属性lang置为初始值 
      $(".txt_industry").attr("lang",&#39;0&#39;);//将下拉列表属性lang置为初始值 
      $(".txt_segmentation").attr("lang",&#39;0&#39;);//将下拉列表属性lang置为初始值 
      $(".customer_busi_status2").attr("lang",&#39;0&#39;);//将下拉列表属性lang置为初始值 
      $("#searchkey").attr("lang",&#39;0&#39;);//将下拉列表属性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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn