小编yvo*_*zoe的帖子

如何使用带有.reset()方法的jQuery重置表单

当我点击重置按钮时,我有可以重置表单的工作代码.然而,在我的代码变得越来越长之后,我意识到它不再起作用了.

 <div id="labels">
        <table class="config">
            <thead>
                <tr>
                    <th colspan="4"; style= "padding-bottom: 20px; color:#6666FF; text-align:left; font-size: 1.5em">Control Buttons Configuration</th>
                </tr>
                <tr>
                    <th>Index</th>
                    <th>Switch</th>
                    <th>Response Number</th>
                    <th>Description</th>
                </tr>
            </thead>
            <tbody>

                <form id="configform" name= "input" action="#" method="get">
                <tr><td style="text-align: center">1</td>
                    <td><img src= "static/switch.png" height="100px" width="108px"></td>
                    <td id="small"><input style="background: white; color: black;" type="text" value="" id="number_one"></td>
                    <td><input style="background: white; color: black;" type="text"  id="label_one"></td>
                </tr>
                <tr>
                    <td style="text-align: center">2</td>
                    <td><img src= "static/switch.png" height="100px" width="108px"></td>
                    <td id="small"><input style="background: white; color: black;" type="text" id = "number_two" value=""></td>
                    <td><input …
Run Code Online (Sandbox Code Playgroud)

javascript forms jquery reset

244
推荐指数
11
解决办法
74万
查看次数

可以在setInterval()中调用clearInterval()吗?

bigloop=setInterval(function () {
              var checked = $('#status_table tr [id^="monitor_"]:checked');
                if (checked.index()===-1 ||checked.length===0 || ){
                    bigloop=clearInterval(bigloop);
                    $('#monitor').button('enable');
                }else{

                        (function loop(i) {                           
                            //monitor element at index i
                            monitoring($(checked[i]).parents('tr'));
                            //delay of 3 seconds
                            setTimeout(function () {
                                //when incremented i is less than the number of rows, call loop for next index
                                if (++i < checked.length) loop(i);
                            }, 3000);
                        }(0)); //start with 0
                }                            
            }, index*3000); //loop period
Run Code Online (Sandbox Code Playgroud)

我有上面的代码,有时它工作,有时它不是.我想知道clearInterval是否真的清除了计时器?因为有这个monitor按钮只有在它monitoring起作用时才会被禁用.clearInterval.outputRemove点击一个被调用的元素时,我有另一个.请参阅以下代码:

//remove row entry in the …
Run Code Online (Sandbox Code Playgroud)

javascript jquery setinterval clearinterval

108
推荐指数
1
解决办法
8万
查看次数

我如何为jQuery做一个switch case?

我有这个if-else语句给了我奇怪的回应......每当我首先选择"输出"时,之后没有其他选择可以出现...仅供参考,我使用多选我所以我可以选择并显示我想要的数量.

 $('#outputText').hide();
    $('#armCB').hide();
    $('#outputCB').hide();
    $('#zoneText').hide();
    $('#counterText').hide();
    $('#flagText').hide();
    $('#sensorText').hide();

('#select-choice-1').change(function(){
        if ($('#output').is(':selected')){
            $('#outputText').show();
        }
        else if ($('#arm').is(':selected')){
            $('#armCB').show();
        }
        else if ($('#zone').is(':selected')){
            $('#zoneText').show();
        }
        else if ($('#counter').is(':selected')){
            $('#counterText').show();
        }
        else if ($('#flag').is(':selected')){
            $('#flagText').show();
        }
        else if ($('#sensor').is(':selected')){
            $('#sensorText').show();
        }
        else{
            $('#outputText').hide();
            $('#armCB').hide();
            $('#zoneText').hide();
            $('#counterText').hide();
            $('#flagText').hide();
            $('#sensorText').hide();

        }
Run Code Online (Sandbox Code Playgroud)

我的if-else声明中有错误吗?或者我必须在这里使用Switch case语句吗?如果是这样,我该怎么办?

HTML:

<div id="display" style=" clear:both">
        <div class="left" style="float:left; width:48%">
        <div data-role="fieldcontain">
            <label for="select-choice-1" class="select">Select Category</label>
            <select name="select-choice-1" id="select-choice-1" data-native-menu="false" data-mini="true" multiple="multiple" size="2">

                <option value="arm" id="arm">Arm</option>
                <option value="zone" id="zone">Zone Input</option>
                <option value="output" id="output">Output</option> …
Run Code Online (Sandbox Code Playgroud)

jquery if-statement switch-statement

11
推荐指数
2
解决办法
6万
查看次数

如何使用jQuery .append()附加图像?

我可以在表格中添加一个字符串来显示状态

$('#test').empty().append("on")
Run Code Online (Sandbox Code Playgroud)

但如果我能显示图像而不是字符串会更好.我试过这个:

$('#test').empty().append(<img src="/static/on.png" height="64px" width="64px">)
Run Code Online (Sandbox Code Playgroud)

但它不起作用.我该怎么办?

javascript jquery

3
推荐指数
2
解决办法
4万
查看次数

javascript正则表达式(x),小数点和单词边界的示例和解释

有人可以在这里为这些特殊字符示例提供更好的解释吗?或者提供一些更清晰的例子?

(X)

模式中的'(foo)'和'(bar)'/(foo)(bar)\ 1\2 /匹配并记住字符串"foo bar foo bar"中的前两个单词.模式中的\ 1和\ 2匹配字符串的最后两个单词.

小数点

例如,/.n /匹配"an"和"on"in"nay,苹果在树上",但不是'nay'.

字边界\ b

/\w\b\w /将永远不会匹配任何内容,因为单词字符永远不会被非单词和单词字符所遵循.

非字边界\ B

/\B../匹配"noonday"中的'oo'(和/y.B./匹配'ye'在"可能是昨天."完全不知道上面的例子显示了什么:(

非常感谢!

javascript

3
推荐指数
1
解决办法
1168
查看次数

保存页面状态。Cookie 还是会话?

我有一个小网络应用程序(只有 1 页),允许用户输入和选择一些选项。输入的文本和选择将以表格的形式显示在另一个 div 中。您可能需要参考此处的示例:http : //jsfiddle.net/xaKXM/5/ 在此小提琴中,您可以输入任何内容,单击submit后将获得文本输入并将它们附加到另一个表中#configtableTable

$('#labels #labelTable tr:last').after(addmore);
$('#configtable #configtableTable tr:last').after(displaymore);
Run Code Online (Sandbox Code Playgroud)

我正在使用cherrypy作为迷你网络服务器(因此主要代码是用python编写的),我知道它在session 这里,但我根本不知道如何使用它,因为给出的示例并不是我真正想要看到的.

仅供参考,我根本没有使用 PHP,所有内容都在一个页面中。我只是显示和隐藏它们。但我希望页面即使在刷新后也能保持显示#configtableTable和隐藏状态#labelTable。请注意,小提琴只是网络应用程序的一部分,它只会在从另一台设备得到回复后才会显示所有这些。

不确定 cookie,因为我发现的所有链接似乎都已损坏。如何jQuery的会议?它适用于我的情况吗?不过我需要一些应用示例:(

好的,总结一下我的问题: 1. 我可以在刷新后保存页面状态吗?如何?上面提到的哪些方法值得一试?有什么例子可以参考吗?或任何其他建议?2.我可以在到达页面后简单地禁用刷新或返回吗?

提前谢谢大家:)

javascript python jquery cherrypy

3
推荐指数
1
解决办法
3060
查看次数

Python如何只获取回复数据的最后2个字节

我将向设备发布一个查询,该设备将返回类似这样的内容(在读取行之后):

['\x03C?01FF00\r']
Run Code Online (Sandbox Code Playgroud)

我想只提取FF00并将回复发布到jquery(发送查询)并将其显示在浏览器上。我怎样才能做到这一点?2 个字节的范围是 0000 到 FFFF。

编辑:回复类型是list.

python jquery python-2.7

1
推荐指数
1
解决办法
5782
查看次数

jQuery(移动):按钮没有隐藏

我面临一个非常奇怪的问题.这是我的代码:

<div id="status">
        <div id="armStatus">
            <div id="armText">
                <fieldset data-role="controlgroup">
                    <legend>Unit</legend>
                    <input type="checkbox" class="CB" name="armCB_1" id="armCB_1" class="custom" data-mini="true" />
                    <label for="armCB_1">Arming Status</label>
                    <p id="armingtext"></p>
                </fieldset>
             </div>
        </div>
        <table class="config" id="status_table">
            <thead>
                <tr>
                    <th colspan="4"; style= "padding-bottom: 20px; color:#6666FF; text-align:left; font-size: 1.5em">Feedback Status</th>
                </tr>
                <tr>
                    <th>Index</th>

                    <th>Feedback Type</th>
                    <th>Feedback Number</th>
                    <th>Status</th>
                    <th class="cHide">Monitor?</th>
                    <th class="cHide">Remove?</th>
                </tr>
            </thead>
            <tbody>
                 <tr>
                 </tr>
            </tbody>       
       </table>
       <button type="button" id="monitor" class="cHide" data-role="button" data-mini="true" data-transition="fade">Monitor</button>

    </div>
Run Code Online (Sandbox Code Playgroud)

如上所示,该按钮与2个表头monitor具有相同的类并且'remove?`.但是当这个叫做:.cHidemonitor?

$(".cHide").hide();
Run Code Online (Sandbox Code Playgroud)

只隐藏了monitor?remove?列,但monitor …

javascript jquery jquery-mobile

1
推荐指数
1
解决办法
5133
查看次数

jQuery:尝试刷新或关闭浏览器时提示用户

场景:我有一个Web应用程序,我将让用户1在表单(#div1)中设置一些值并将其显示给下一个用户(在用户1之后没有关闭浏览器来到浏览器)(显示将显示在#div2#div1将被隐藏).但是,如果用户2刷新浏览器,则所有值都将消失.

问题:如何在用户尝试刷新浏览器时提醒用户?Web应用程序将打开Midori,Web服务器将打开CherryPy.

或者有没有办法保存会话而不管刷新?如何?

javascript jquery html5

0
推荐指数
1
解决办法
4514
查看次数