我想在drupal中添加两个按钮。我使用表id并附加但它不起作用。我不知道是什么问题,并且在控制台中没有显示错误。
这是代码。请帮忙
(function($){
$('#edit-submitted-new-table-element').appendTo('<a href="javascript:void(0);" class="addmorebtn form-submit">Add More</a> <a href="javascript:void(0);" class="hidebtn form-submit">Hide it</a>');
$('.hidebtn').css('display', 'none');
alert('h1');
var numcount = 0;
$('#edit-submitted-new-table-element .addmorebtn').live('click', function(){
numcount++;
if(numcount >0 && numcount < 2){
$('#edit-submitted-new-table-element tr:nth-last-child(2)').css('display', ' table-row');
}
else if(numcount >1 && numcount < 3){
$('#edit-submitted-new-table-element tr:last-child()').css('display', ' table-row');
$('.addmorebtn').css('display', 'none');
$('.hidebtn').removeAttr('style');
$('.hidebtn').css('display', 'inlne-block');
}
});
$('#edit-submitted-new-table-element .hidebtn').live('click', function(){
if(numcount >= 2 && numcount < 3){
$('#edit-submitted-new-table-element tr:last-child().odd').removeAttr('style');
}
else if(numcount >=1 && numcount < 2){
$('#edit-submitted-new-table-element tr:nth-last-child(2).even').removeAttr('style');
$('.hidebtn').css('display', 'none');
$('.addmorebtn').removeAttr('style');
$('.addmorebtn').css('display', 'inline-block');
}
numcount--;
});
}(jQuery));
I want to add two button after table in drupal. I use table id and append but it is not working...
I don't know what is the problem and no error is showing in console.
Here is code . Please help
答案 0 :(得分:0)
您正在使用appendTo
代替append
来介绍您的代码。改变它:
$('#edit-submitted-new-table-element').append(...)
此外,您还必须更改正在使用的选择器。例如last-child()
不正确。为此更改:
$('#edit-submitted-new-table-element tr:last-child')...
$('#edit-submitted-new-table-element tr.odd:last-child').removeAttr('style');
$('#edit-submitted-new-table-element tr.even:nth-last-child').removeAttr('style');
希望它有所帮助。