【发布时间】:2013-11-19 03:59:27
【问题描述】:
我有一个默认禁用的提交按钮,并且在 src 属性中有一个灰色的图像。
这是 HTML:
<form>
<select id="item_location">
<option value="">- Choose Destination -</option>
<option value="US">US</option>
<option value="CN">Canada</option>
<option value="IN">International</option>
</select>
<input class="submit" type="image" src="http://website.com/images/btn_buynow_LG--disabled.png" border="0" name="submit" disabled>
</form>
默认情况下,用户必须选择国家。 When a country is selected that has a value, I'd like to update the image and remove the disabled attribute as long as the value of the dropdown option isn't blank.
这是我到目前为止提出的 jQuery,但它需要根据选择 item_location 选择框的值来切换禁用属性。
function submitButton() {
jQuery(".submit").change(function() {
if (jQuery("#item_location") !== "" {
jQuery(".submit").attr("src", "http://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif").removeAttr("disabled");
});
});
}
【问题讨论】:
标签: javascript jquery html forms