亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用jQuery向按鈕添加操作

使用jQuery向按鈕添加操作

慕桂英546537 2019-04-18 14:15:49
我有一個表格,它顯示不同級別的數據(父,子,孫子),當我點擊它顯示與子級別相關的新行的父級時,如果我點擊子級,它會顯示第三級別作為具有更多行的孫子。我想要做的是在每個記錄上添加一個帶有“+”符號的按鈕,所以當我點擊它時,我會看到第二個級別,并用“ - ”符號將該按鈕從父級切換到另一個,以模擬擴展和折疊功能,我想為子級別也這樣做?,F在,如果我點擊一行,列會展開或折疊,但如果我點擊要添加的按鈕,我想要這樣做。這是我的代碼:    $('.drillDown tr td:last-child, .drillDown tr th:last-child').hide();$('.drillDown tr td:first-child, .drillDown tr th:first-child')     .dblclick(function(){     $('.drillDown tr td:last-child, .drillDown tr th:last-child').show();})     $('table.drillDown').each(function() {         var $table = $(this);         $table.find('.parent').dblclick(function() {             console.log( "*****Click on Parent" );             $(this).nextUntil('.parent', ".child").toggle("fast");              $(this).nextUntil('.parent', ".grandson").hide("fast");         });         $table.find('.child').dblclick(function() {             console.log( "*****Click on child" );             $(this).nextUntil('.child', ".grandson").toggle("fast");          });         var $childRows = $table.find('tbody tr').not('.parent').hide();         $table.find('button.hide').dblclick(function() {             $childRows.hide();         });         $table.find('button.show').dblclick(function() {             console.log("*****Click on Child");             $childRows.filter('.child').show();         });         $table.find('tr.child').dblclick(function(){             $(this).nextUntil('.child').show()         });     });而且我也完整的例子https://jsfiddle.net/ny6qcxtd/2/謝謝!
查看完整描述

6 回答

?
HUX布斯

TA貢獻1876條經驗 獲得超6個贊

changed with following fiddle

小提琴


查看完整回答
反對 回復 2019-05-07
?
素胚勾勒不出你

TA貢獻1827條經驗 獲得超9個贊

也許你可以使用這樣的東西:

$(".classOfButton").click(function() {
                $(".classOfWhatYouWantToExpand").fadeToggle("slow", "linear")
            });

因此,在單擊按鈕時使用jQuery .fadeToggle()函數。只需注意你的目標是什么,并適當地使用類或id。

fadeToggle() jQuery .click 
()


查看完整回答
反對 回復 2019-05-07
?
不負相思意

TA貢獻1777條經驗 獲得超10個贊

$("#target").click(function() { 
   alert("click event"); });$("#target").submit(function() { 
   alert("submit event"); });


查看完整回答
反對 回復 2019-05-07
?
蕭十郎

TA貢獻1815條經驗 獲得超13個贊

只需綁定按鈕單擊功能,請參閱下面的代碼。

為了exa。

$( "#dataTable tbody tr" ).on( "click", function() {
  console.log( $( this ).text() );});

為你的代碼看起來像,

$( "#target" ).on( "click", function() {
 console.log( $( this ).text() );});


查看完整回答
反對 回復 2019-05-07
  • 6 回答
  • 0 關注
  • 937 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號