当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - how to can stop button by jquery

问题描述:

I want to know how can all button stopped

When up to (*)

here

HTML

<table id='a' border='2'>

<tr>

<td>1 = <input type='submit' value='send' onclick=' fs (this)'/></td>

</tr>

<tr>

<td>2 = <input type='submit' value='send' onclick=' fs (this)' /></td>

</tr>

<tr>

<td>*3 = <input type='submit' value='send' onclick=' fs (this)'/></td>

</tr>

<tr>

<td>4 = <input type='submit' value='send' onclick=' fs (this)'/></td>

</tr>

<tr>

<td>5 = <input type='submit' value='send' onclick=' fs (this)' /></td>

</tr>

</table>

</body>

script jquery

function fs(el){

alert("hello");

}

$(function(){

$("#a tr").each(function(i ,v){

setTimeout(function() {

$(v).find(":submit").click();

}, (i + 1)* 500);

var click = $(this).find("td:eq(0)").text().match(/\*/);

if(click == '*'){

$(v).find(":submit").attr("disabled","disabled");

}

});

});

here

<td> * 3 = <input type='submit' value='send' onclick=' fs (this)'/> </ td>

Must stop all the buttons below it when he got (*)

<td> 4 = <input type='submit' value='send' onclick=' fs (this)'/> </ td>

<td> 5 = <input type='submit' value='send' onclick=' fs (this)'/> </ td>

But did not stop, but she works when he got (*)

out the alert ("hello");

How do I stop all the buttons when it gets to *

I want to i stoped all the buttons under (*)

<td> * 3 = <input type='submit' value='send' onclick=' fs (this)'/> </ td>

<td> 4 = <input type='submit' value='send' onclick=' fs (this)'/> </ td>

<td> 5 = <input type='submit' value='send' onclick=' fs (this)'/> </ td>

and thanks =)

网友答案:

You can create a condition within their function as follows:

    function fs(el) {
        var value = el.attr('disabled');
        if (value) {
            el.preventDefault();
            return false;
        }
    }

I hope that will help.

分享给朋友:
您可能感兴趣的文章:
随机阅读: