我使用的按钮必须有背景图像,但<input type="submit">不能有背景图像。
例如,我可以对图像使用Html.ActionLink:
@Html.ActionLink("Add to Cart", "AddCart","Products", new { id = Model.product_id,},new { @class = "**add-cart item_add"** })class = "add-cart item_add“在输入中不起作用
我该怎么办?非常感谢。
发布于 2017-08-01 11:20:08
类型为submit的输入按钮应该是可设置样式的;但是,对于image button,您可以使用<button type="submit"或<input type="image"。对于图像按钮,设置src属性;对于按钮,添加一个background-image: url("../images/something.png")作为示例。
发布于 2017-08-01 19:31:41
使用一个按钮,在该按钮的on click事件上,使用javascript对服务器进行调用(如果需要,则使用ajax)。你的代码看起来会像这样:
<button id="yourBtnName" class="add-cart item_add">Submit</button>
<script>
$('#yourBtnName').click(function(e) {
e.preventDefault();
//do whatever you want to do on the button click event
});
</script>https://stackoverflow.com/questions/45428080
复制相似问题