Gets select tab selected text with jquery option value and

<% @ Page Language = "Java" contentType = "text / HTML; charset = UTF-. 8" the pageEncoding = "UTF-. 8"%>
! <DOCTYPE HTML the PUBLIC "- // the W3C // the HTML 4.01 Transitional // EN the DTD "" http://www.w3.org/TR/html4/loose.dtd ">
<HTML>
<head>
<Script type =" text / JavaScript "the src =" ../../../ .. /js/common/jquery-1.6.2.js "> </ Script>
<Script type =" text / JavaScript ">
function doSome () {
Alert ($ (" # SEL Option: Selected ") text ().) ; // method one: get the selected option select the label text.
alert ($ ( "# sel" ) find ( "option: selected") text ()..); // Method Two: Get the text select the label of the selected option.

alert ($ ( "# sel option : selected") val ().); // Method one: get the value of value of the selected option in select tag of.
alert ($ ( "# sel" ) find ( "option: selected") val ()..); // Method Two: Gets the value of the select tag value of the selected option.
// ------------------------------ handsome ,, following the dividing line focused --------- -----------------------

// When the option is this: <option> cc </ option >. That is not the time value of the property. Naturally there is no value value.
// jquery this time is very tangled: write a piece of code I get the value of value, but there is no option to find the value of property.
// Well, the option of text out to you.
// So you select the <option> cc </ option> this option, you will find that the top four alert out of the value is the same. The text is option.
// want to get the value of the value of the option in the first option must have a value attribute ah! ! !
}
</ Script>
</ head>

<body>
<div>
<select id="sel" onchange="doSome();">
<option value="aa">bb</option>
<option>cc</option>
</select>
</div>
</body>
</html>

原文链接:https://blog.csdn.net/u013698807/article/details/79174111

Guess you like

Origin www.cnblogs.com/junjun-001/p/11777045.html