我有Select并禁用所有值,如何将值设置为Select?
driver.findElement(By.xpath("//table[@id='ctl00_pagecontent_ctl01']/..//following::tr[@class='ui-widget-content jqgrow ui-row-ltr']/td[1]/a")).click();
答案 0 :(得分:3)
您必须具体说明要返回的元素的值。
alert($("#testselect option:selected").val());
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<select id="testselect">
<option disabled>1</option>
<option disabled>2</option>
<option disabled selected>3</option>
</select>
答案 1 :(得分:3)
试试这个==&gt;
alert($('#testselect option[disabled]:selected').val());
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<select id="testselect">
<option disabled>1</option>
<option disabled>2</option>
<option disabled selected>3</option>
</select>