2

asp.netパネル内の子フォーム要素を有効/無効にするためにasp.netを作成しています。このスクリプトは編集フォームを有効にしますが、2回目にクリックした後は無効にしません。

 <script type="text/javascript">
    $(function () {
        //createing toggle
        $("#check").button();

        $("[id$='check']").data('isenabled', true); //enabled assumption
        //disabled all input form 
        $("[id$=p_taskInfo]").children().prop("disabled", "disabled");
        $("input[name='check']").click(function () {
            var curruntState = $(this).data('isenabled');
            if (curruntState) {
                $("[id$=p_taskInfo]").children().removeProp("disabled");

            }
            else {
                $("[id$=p_taskInfo]").children().prop("disabled", "disabled");
            }
            $(this).data('isenabled', !currentState);
        }); //EOF click function 
    });//EOF function 
</script>
4

1 に答える 1

2

という単語currentStateにバグがあり、他の場所に書いていcurruntStateます。

これは、正しいキーワードを使用したコードのサンプルです。正常に動作しています (Google chrome でコンソールを開いて結果を表示します)。

http://jsfiddle.net/zHmh9/4/

于 2012-12-19T17:50:01.077 に答える