这应该是这么简单。基本上我希望人们能够从下拉列表中进行选择,并且我希望将值和实际文本作为两个单独的项目传递。所以从下面我想要一个价值为类价格,一个价值为类别。因为它是我只能得到实际的“价值”。
<select name="class" id="class" value="">
<option selected="selected" value="none">none</option>
<option value="$75.00">KinderDrawing for Pre-K Thursday 10am (Mar 20 to Apr 24) </option>
<option value="$75.00">KinderDrawing for Pre-K FULL Saturday 9:00am (Apr 5 to May 10) </option>
<option value="$55.00">Toddler Art Tuesday 10am (Mar 18 to Apr 22)</option>
<option value="$55.00">Toddler Art Saturday 10:30am (Apr 5 to May 10)</option>
</select>
答案 0 :(得分:0)
您可以使用jquery在select
$("#class").change(function() {
var selectedOption = $(this).find("option:selected");
var text = selectedOption.text();
var value = selectedOption.val();
});