使用Jquery显示自定义警报 [英] Show custom alert using Jquery

查看:90
本文介绍了使用Jquery显示自定义警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我现在有一个带有2个复选框和一个按钮的表单,我需要做的是,如果用户在我们选中任何可用复选框的情况下单击按钮,我想显示自定义警告,说选择一个 ..如果选择了一个,我不想显示警报...

为此,我使用了以下

http://www.abeautifulsite.net/blog/2008/12/jquery-alert-dialogs / [^ ]

进行了一些更改,如下所示

Hi all I am having a form with 2 check-boxes and a button what I need to do is if the user clicks on a button with our checking any check-box available, I would like to show custom alert saying select one.. If one is selected I don''t want to show the alert...

for this I used the following

http://www.abeautifulsite.net/blog/2008/12/jquery-alert-dialogs/[^]

with some changes as follows

<script type="text/javascript">

        $(document).ready(function () {
            var atLeastOneIsChecked = $('#checkArray :checkbox:checked').length > 0;

            if (atLeastOneIsChecked == 0) {
                $("#alert_button").click(function () {
                    jAlert('This is a custom alert box', 'Alert Dialog');
                });
            }
        });

    </script>





<form id="form1" runat="server">
    <fieldset id="checkArray">
    <input type="checkbox" name="chk[]" value="Apples" />
    <input type="checkbox" name="chk[]" value="Bananas" />
</fieldset>
        <p>
            <input id="alert_button" type="button" value="Show Alert" />
        </p>
    </form>



但是我对这两种情况都保持警惕,任何人都可以帮助我..



But I am getting alert on both the case can any one help me..

推荐答案

(document).ready(function(){ var atLeastOneIsChecked =
(document).ready(function () { var atLeastOneIsChecked =


('#checkArray:checkbox:checked').length> 0; if(atLeastOneIsChecked == 0){
('#checkArray :checkbox:checked').length > 0; if (atLeastOneIsChecked == 0) {


(#alert_button").click(function(){ jAlert('这是一个自定义警报框','Alert Dialog'); }); } }); < /script >
("#alert_button").click(function () { jAlert('This is a custom alert box', 'Alert Dialog'); }); } }); </script>





<form id="form1" runat="server">
    <fieldset id="checkArray">
    <input type="checkbox" name="chk[]" value="Apples" />
    <input type="checkbox" name="chk[]" value="Bananas" />
</fieldset>
        <p>
            <input id="alert_button" type="button" value="Show Alert" />
        </p>
    </form>



但是我对这两种情况都保持警惕,任何人都可以帮助我..



But I am getting alert on both the case can any one help me..


这篇关于使用Jquery显示自定义警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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