几天前我在这里问了如何在表单中预先选择一个选项来做一个下拉菜单。 我已经得到了一个答案,并尝试了它和我在网上找到的一些其他建议,所有这些都失败了。 我附上了两张照片,显示了我所做的事情,所以希望你们能够帮助我。Jquery在插件中预选下拉菜单选项
(请记住,我使用的插件,只允许我加入的代码不能编辑给定的一个)
NUM1 thats how the plugin made the form, i cannot edit it
NUM2 thats what i have tried and it did not work
编辑
这里是pulgin制造的代码:
<label class="fitText" style="font-size: 16px;">Product</label>
<select name="Product" data-export-field="">
<option value=""> - Product - </option>
<option value="A" data-price="0">
A
</option>
<option value="B" data-price="14">
B
(+$14.00)
</option>
</select>
我做了什么:
<script>
$(window).load(function() {
$('#Product option[value=A]').attr('selected','selected');
});
</script>
希望你们能帮助我! :d
感谢 Yarin
有什么方法可以将代码复制并粘贴到问题中?从图像调试代码似乎效率低下。 –
完成,你是对的,谢谢 –