我無法讓我的jQuery代碼自動選擇一個無線電框。 這裏是我的html:jQuery自動選擇無線電框不工作
<div class="formField rsform-block rsform-block-existingcustomer" style="margin-bottom: -22px;">
<!--<input name="form[existingCustomer]" type="radio" value="Yes" id="existingCustomer0" /><label for="existingCustomer0">Yes</label><input checked="checked" name="form[existingCustomer]" type="radio" value="No" id="existingCustomer1" /><label for="existingCustomer1">No</label><br/>
<span id="component100" class="formNoError">Please tell us if you're an existing customer.</span>-->
Are you an existing client?<br>
<label for="existingCustomer0" class="radio"><span class="icon"></span><span class="icon-to-fade"></span>Yes
<input name="form[existingCustomer]" type="radio" value="Yes" id="existingCustomer0" class="addRadio">
</label>
<label for="existingCustomer1" class="radio checked"><span class="icon"></span><span class="icon-to-fade"></span>No
<input checked="checked" name="form[existingCustomer]" type="radio" value="No" id="existingCustomer1" class="addRadio" style="display:none;">
</label>
</div>
,這裏是jQuery代碼的片段,是應該做的是:
if(aaid) {
var num_one = aaid;
jQuery('input[value="Yes"]').prop('checked', true);
有誰看到這個問題?我正在嘗試自動選擇「是」複選框,以便它會激活下一個創建下拉菜單的部分。
在此先感謝! :)
你是什麼意思,這個自動選擇?即在頁面加載時,這個無線電被檢查。或者你只是想點擊選擇它。 – super
在頁面加載時會被檢查。 –