0

「作成」ボタンをクリックすると作成される10個のボタンがあります。

「作成」をクリックしたときにこれらすべてのボタンもクリックするにはどうすればよいですか?

function a() {
    selectAll();
    jQuery(selectAllValues());
};

function selectAllValues() {
    for(var i = 0; i < array.length; i++) {
        document.getElementById("select" + array[i]).click();
    }
};

問題は、ボタンが作成されてもクリックされないことです。

4

2 に答える 2

1

なぜそれらすべてをクリックしたいのですか?これらは実際に「チェック済み」としてマークしようとしているチェックボックスですか?

//If checkboxes then try
$('#select'+array[i]).prop('checked', true);

これらが本当にボタンである場合、それらが初期化する「onClick」関数を手動で初期化しないのはなぜですか?

for(var i = 0; i < array.length; i++) {
    //call the onClick function yourself here
}

詳しく教えてください

編集:

function selectAllValues() {
    for(var i = 0; i < array.length; i++) {
        $('#select'+array[i]).prop('checked', true);

        //code to create tables

        //loop through tables
        $('tableselector').each(function(key,value){
            //check the checkboxes within the tables
            $(this).find('input[type="checkbox"]').prop('checked', true);
        });
    }
};
于 2013-07-10T19:21:34.183 に答える