いつもお世話になります。
下記を参考に、作成を進めております。
http://qiita.com/azu_rs/items/b38c05b77cf286f9219f
「ボタンをクリックしたら実行」ではなく、
「ページを読み込んだら実行」にしたいのですが、
上手く実行させることができず悩んでおります。
恐れ入りますが、ご教示の程よろしくお願いいたします。
javascript
1 $.fn.table_transpose = function(){ 2 3 // idを取得 4 t_id = '#'+$(this).attr('id'); 5 6 // 後で削除するため、既存の行にクラス付与 7 $(t_id+' tr').addClass('temptr'); 8 9 // thead,tbodyは行列変換で意味をなさなくなるのでタグ除去 10 $(t_id+' thead,'+t_id+' tbody').children().unwrap(); 11 12 // 入れ替え 13 $(t_id+' tr:first td,'+t_id+' tr:first th').each(function(){ 14 var tds = $(this).index()+1; 15 $(t_id).append('<tr />'); 16 $(t_id+' tr.temptr').each(function(){ 17 $(t_id+' tr:eq('+$(this).index()+') > :nth-child('+tds+')').clone(true).appendTo(t_id+' tr:last'); 18 }); 19 }); 20 21 // クラス削除 22 $(t_id+' tr.temptr').remove(); 23 return this; 24 25 } 26 27 /* ボタンクリックしたらテーブルの行列を入れ替える */ 28 $('#button1').live('click',function(){ 29 $('#table1').table_transpose(); 30 });
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。