客户端上的启用和禁用按钮 [英] enable and disable button on client side

查看:78
本文介绍了客户端上的启用和禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好朋友,我有一个视图,其中有很少的选项卡,在其中一个具有搜索和购物车的选项卡中,我在carter中有一个提交"按钮.要将项目添加到购物车中,我有一个添加至"面板中的购物车"按钮会弹出,当我单击该商品时,当我单击添加到购物车"时,它会将选定的商品发送到cart.now.现在,我想禁用该按钮,直到将某些商品添加到购物车中为止.通过单击添加到购物车"将商品添加到该购物车后,我希望启用该按钮.如果从购物车中删除了这些商品,则需要再次禁用该按钮.我需要在客户端执行此操作(因为我所有的脚本都在客户端执行).下面是该按钮以及用于禁用该按钮的脚本.当我点击购物车中的按钮时,该按钮已被禁用,但我无法将其重新启用.

面板中的添加到购物车"按钮

Hi friends, I have a view which which has few tabs, in one of the tab i have search and a cart, i have a "submit" button in the cart.to add items into cart i have a "add to cart" button in a panel which pop when i click on the item,and when i click "add to cart" it send the selected item into the cart.now i want to disable that button till some items are added into the cart and as soon as items are added to that cart by clicking the "add to cart" i want that button to be enabled.and if the items are deleted from the cart i need to disable the button again. i need to do this on the client side(as all my scripting is on client side). below is the button and the script for disabling the button. The button has disabled but i''m not able to enable it back, when i click the ad to cart.

Add to cart button in the panel

<input class='button' type='button' onclick=\"Add to cart(\'" + hash + "\');\" value='add to cart'/>


我有一个添加到购物车的功能,其中包含有关商品的信息

提交按钮位于"div"内部,当我们单击添加到购物车"时,所选项目将发送到具有提交和取消订单的"div"内部.


I have a function for the add to cart which has the information about the item

submit button is inside a "div" and when we we click add to cart the selected item is sent inside this "div" which has submit and cancel order.

<button id="submit" >Submit</button>

<script type="text/javascript">
    $(document).ready(function () {
       
        $(function () {
                        //Set button disabled
                        $("#submit").attr("disabled", "disabled");
                       });

                       $('#submit').trigger('change');
        });

</script>


现在,当我在面板中单击添加到购物车"时,如何启用


now how do i enable the submit button in the

中的提交按钮

推荐答案

(文档).ready(功能(){
(document).ready(function () {


(功能(){ // 设置按钮已禁用
(function () { //Set button disabled


( #submit").attr( 已禁用" 已禁用"); });
("#submit").attr("disabled", "disabled"); });


这篇关于客户端上的启用和禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆