1
我想追加由OPTGROUP &刪除我能夠通過使用下面的js代碼移除,但不能夠通過OPTGROUP追加可以請你檢查我的js小提琴我想追加與通過OPTGROUP下拉
JS刪除代碼
$j("#shipping_method optgroup[label='Free Shipping']").remove();
<fieldset>
<select name="shipping_method" id="shipping_method" style="width:250px;" class="required-entry">
<option value="">Please select a shipping method...</option>
<optgroup label="Free Shipping" style="font-style:normal;">
<option value="freeshipping_freeshipping">
Standard Shipping (SmartPost) (2 - 7 Business Days) - $0.00
</option>
</optgroup>
<optgroup label="FedEx" style="font-style:normal;">
<option value="fedex_FEDEX_GROUND">
Ground (2 - 4 Business Days) - $18.07
</option>
<option value="fedex_FEDEX_2_DAY">
2-day (2 - 3 Business Days) - $30.62
</option>
<option value="fedex_STANDARD_OVERNIGHT">
Standard Overnight (1 - 2 Business Days) - $81.34
</option>
</optgroup>
</select>
</fieldset>
<a href="#" class="reset-signature" style="display: none">Clear Shipping Selection</a>
<p class="actions">
<button id="update_shipping_method_submit" type="submit" class="button" style="display: none;"><span><span>Update Shipping Method</span></span></button>
</p>
https://jsfiddle.net/7k6evkt8/
不工作請與js小提琴解釋 –
https://jsfiddle.net/k88g83pu/ 林不知道我誤解你的問題? – vicnoob