简体   繁体   English

Html > 购物车按钮

[英]Html > shopping cart button

I am wondering what should I properly use for an HTML table that has an add to cart buttons and buy all button.我想知道应该为具有添加到购物车按钮和购买所有按钮的 HTML 表正确使用什么。

So, Should I use那么,我应该使用

<input class="btn" type="button" value="Buy -Shopping cart"/> or can I use <input class="btn" type="button" value="Buy -Shopping cart"/>或者我可以使用

<a href="#" title="Buy Shopping card"><b>&#43;</b><img width="16" height="10" alt="Cart" src="images/cart.png"></a>

Also, I would need to enable and disable those buttons using JavaScript另外,我需要使用JavaScript启用禁用这些按钮

I'd say that both of your initial suggestions would be fine, it's more a matter of how you'd like your buttons to be styled.我会说您最初的两个建议都可以,这更多的是您希望按钮的样式。 If you use the <input type='button'> method, it'll be a bit harder to use CSS to customize your buttons.如果您使用<input type='button'>方法,使用 CSS 自定义按钮会有点困难。 Links, on the other hand, are easier to style.另一方面,链接更容易设置样式。 So, if you need custom-looking buttons, go with the <a href="#" title="Buy Shopping card"><b>&#43;</b><img width="16" height="10" alt="Cart" src="images/cart.png"></a> version.因此,如果您需要自定义外观的按钮,go 与<a href="#" title="Buy Shopping card"><b>&#43;</b><img width="16" height="10" alt="Cart" src="images/cart.png"></a>版本。

That purely depends on what your shopping cart's code looks like.这完全取决于您的购物车代码的样子。 In general, I'd say people use buttons for internal shopping carts (that are a part of a POST form) - and input type image can be used as well for those - and links for external shopping carts (like PayPal).一般来说,我会说人们使用内部购物车的按钮(这是 POST 表单的一部分) - 输入类型的图像也可以用于这些 - 以及外部购物车的链接(如 PayPal)。

To enable/disable with javascript, you could have it dynamically insert "disabled=true" for the button or take out the link and replace it with "#" for the link.要启用/禁用 javascript,您可以让它为按钮动态插入“disabled=true”,或者取出链接并用“#”代替链接。 But again, depends on your situation.但同样,取决于你的情况。

I wouldn't use an a-tag for this unless you want search engine spiders to come and click on all your add to cart and buy button -links.除非您希望搜索引擎蜘蛛来点击您所有的添加到购物车和购买按钮链接,否则我不会为此使用 a-tag。 Think about it:)想想看:)

No but seriously, a-tags is for linking pages together, and <input type="submit"> or <button> tags are for actions that changes states.不,但严肃地说,a-tags 用于将页面链接在一起,而<input type="submit"><button>标签用于更改状态的操作。 Adding an item to a cart or buying something is an action that changes a state.将商品添加到购物车或购买商品是更改 state 的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM