根据使用jquery的文本,将按钮更改为图像? [英] Change button to image depending to text using jquery?
问题描述
我的在线商店有一个结帐页面,其中一个字段是一个折扣优惠券代码,旁边是一个更新总计按钮。下一列显示折扣。
I've got a checkout page on my online store, and one the fields is a for a Discount Coupon code, next to which is an 'update total' button. The next column shows the discount.
--------------- ——————————————
enter code:| | |update total| - $0.00
--------------- ——————————————
当用户输入正确的代码并按下更新页面时,将以正确的折扣金额重新加载:
When the user enters a correct code and presses update the page loads again with the correct discount amount:
--------------- ——————————————
enter code:| 1234 | |update total| - $10.00
--------------- ——————————————
我想让用户看到一个刻度图像而不是按钮,所以他们不会困惑,并再次点击更新,如下:
I want the user to see a tick image instead of the button, so they don't get confused and click update again, like this:
---------------
enter code:| 1234 | tick image - $10.00
---------------
是否可以用jquery做到这一点?我想它会检查金额,看看它不是0.
html看起来大致像这样:
Is it possible to do this with jquery? I guess it would check the amount to see if it was not 0. The html looks roughly like this:
<td>
<input type='text' class='couponinput' name='coupon_num' id='coupon_num' value='' />
<input type='submit' class='update-button' value='Update' />
</td>
<td class="lastcolumn">
<span id="coupons_amount" class="pricedisplaycart" style="font-weight:bold; color:black;" >-£0.00</span>
</td>
推荐答案
隐藏并插入图片替换它)...
Hide it and insert in image after it (which essentially replaces it)...
$('input[type=submit]').hide().after('<img src="tickImage.jpg" />");
这篇关于根据使用jquery的文本,将按钮更改为图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!