0
我無法從下拉框中選擇元素。 這裏是div無法使用javascript設置下拉列表中的值
<div class="select ccMonth" id="payflow-form-ccMonth-select">
<select name="expMonth" class="month payflow-form-ccMonth-select hidden" id="payflow-form-ccMonth-select-select">
<option value="Month">Month</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
<span name="expirationMonthSpan">Month</span><ul>
<li data-index="0">Month</li>
<li data-index="1">1</li>
<li data-index="2">2</li>
</ul>
</div>
當我在Chrome但是運行此
document.getElementById('payflow-form-ccMonth-select-select');
當我嘗試下面的DIV返回正確,它不會在下拉框中設置值,我想。
document.getElementById('payflow-form-ccMonth-select-select').selectedIndex=1;
我也試圖用點擊()擴大下拉框,但它仍然無法工作,它首先重點。
document.getElementById('payflow-form-ccMonth-select-select').click();
document.getElementById('payflow-form-ccMonth-select-select').selectedIndex=1;
我也試過這個,沒有工作或者
document.getElementById('payflow-form-ccMonth-select-select').value = 1;
什麼我可能會丟失任何提示? 感謝
經過你的代碼,它的工作檢查http://jsbin.com/zez/2/edit – Champ