English 中文(简体)
• 如何在我作为p.net mvc 3使用jquery的 as子里排除所有“提交”纽芬兰语
原标题:How can i disable all the"submit" buttons inside my asp.net mvc 3 using jquery
  • 时间:2012-05-06 02:07:54
  •  标签:
  • jquery

我想写一个文字,在用户点击所有提交纽芬兰语时,即写出以下Jquery书,对所有观点都说不错,但并不奏效:

$(document).ready(function () {
    $(":input[type=submit]").click({
        this.attr( disabled ,  disabled );

    });
})

So what is wrong wiht my code? BR

最佳回答
$(document).ready(function () {
    $("input[type= submit ]").click(function() {
         $(this).prop( disabled , true);
    });
});

$(document).ready(function () {
    $("input[type= submit ]").click(function() {
         this.disabled = true;
    });
});

If the submit button is submitting a f或m, you will have to prevent the default action that will reload the page:

    $("input[type= submit ]").click(function(e) {
         e.preventDefault();
         $(this).prop( disabled , true);
    });
});
问题回答

如何做这样的事情:

$(document).ready(function () {
    $("form").submit({
        $("input[type=submit]").attr( disabled ,  disabled );
        return true;
    });
});

以上是你打算做些什么的更好办法。 如果你坚持要求您的守则发挥作用,则删除“条码”:,然后在“条码”上填写。

你们说,你想让所有各州都感到不舒服,但“这”关键词仅指导致这一事件被推翻的项目,因此你需要:

$(document).ready(function () {
    $("input[type= submit ]").click({
        $("input[type= submit ]").attr("disabled","disabled");

    });
});

The reason your script doesn t work is because this is referring to the HTML element, not the jQuery object. You need to wrap it in a jQuery object to run functions such as attr on it:

$(this).attr( disabled ,  disabled );

此外,如果你想要打听all<>/strong>提交纽芬兰语,那么你就需要做新的选择,并且可以全部放弃。 这部法律应当做到:

// Passing a function to $ will run it on document ready
$(function () {
    $("input[type=submit]").click({
        // Select all submit inputs and disable them
        $( input[type=submit] ).attr( disabled ,  disabled );
    });
});

现在,当有人被点击时,所有提交纽芬兰语的人都应残疾。

我认为,这是你期待的:

$("input[type=submit]").click(function() {
    $(this).attr( disabled ,  disabled );

    // if you want to disable all buttons on the form do the following
    // $("input[type=submit]").attr("disabled", "disabled");
});

<><>Edit>:

adeneo是正确的。 使用<代码>prop(<>方法”可能是一个好的想法。 我从来没有过通过<条码>(残疾、残疾)

然而,这一格丽论坛职位在,please-explain-attr-vs-prop-change-in-1-6上,可能进一步解释人们在使用倾斜方法时有分歧的原因。 她们最有可能成为现实而不是残疾。

不含“:”投入选择器的提炼,使用美元。

$(function () {
    $("input[type=submit]").click(function() {
        $(this).attr( disabled ,  disabled );
    });
})

FYI——我用短手提子为美元(文件)。 准备就绪。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签