This article describes the method of obtaining the text value in select in JavaScript. Share it for your reference, as follows:
If you don't say anything else, look at the code first:
Method 1:
<select name="parent_id" onchange="setTitleAndLinkByGoodsCategory(,[].text);" > <option value="0">Please select product category</option> <option value="1" >Home appliances</option> <option value="2" >Digital</option> <option value="3" >apparel</option> </select>
Among them, get the value, [].text get the value of home appliances, digital, clothing
Method 2:
<script language="javascript"> function chk(){ var obj = ("sel"); var strsel = [].text; if (confirm("Confirm to select"+strsel+"Do you?")){ }else{ } } </script> <select name="sel" onchange="return chk()"> <option value=1>a001</option> <option value=2>a002</option> <option value=3>a003</option> </select>
For more information about JavaScript, readers who are interested in reading this site's special topic:A complete collection of JavaScript event-related operations and techniques》、《Summary of JavaScript DOM skills》、《Summary of JavaScript Errors and Debugging Skills》、《Summary of JavaScript data structure and algorithm techniques》、《Summary of JavaScript traversal algorithm and skills"and"Summary of JavaScript mathematical operations usage》
I hope this article will be helpful to everyone's JavaScript programming.