คัดลอกรหัสดังนี้: var obj = document.getElementById ("testSelect"); // ค้นหารหัส
ดัชนี var = obj.selectedIndex; // เลือกดัชนี
var text = obj.options [index] .text; // เลือกข้อความ
var value = obj.options [index] .value; // เลือกค่า
รับเลือกค่าเลือกใน jQuery
วิธีแรก
การคัดลอกรหัสมีดังนี้: $ ('#testselect ตัวเลือก: เลือก'). text (); // ข้อความที่เลือก
$ ('#testselect ตัวเลือก: เลือก'). val (); // ค่าที่เลือก
$ ("#testSelect") รับ (0) .SelectedIndex; // index
วิธีที่สอง
การคัดลอกรหัสมีดังนี้: $ ("#tesetSelect") ค้นหา ("ตัวเลือก: เลือก"). text (); // ข้อความที่เลือก
$ ("#tesetSelect") ค้นหา ("ตัวเลือก: เลือก"). val ();
$ ("#tesetSelect") ค้นหา ("ตัวเลือก: เลือก") รับ (0) .SelectedIndex;
ข้างต้นคือเนื้อหาทั้งหมดของ JavaScript เพื่อรับค่าที่เลือกที่เลือกโดยแท็ก SELECT ฉันหวังว่ามันจะให้ข้อมูลอ้างอิงและฉันหวังว่าคุณจะสนับสนุน wulin.com มากขึ้น