jQuery DataTables将div附加到特定位置

时间:2015-08-17 12:43:02

标签: javascript c# html asp.net-mvc datatables

我有代码:

<div class="addButton col-lg-6">
    <button type="button" class="btn btn-primary" data-toggle="modal">BTN</button>
</div>
<div class="table-responsive">
    <div id="PositionDataTable2_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
        <div id="PositionDataTable2_processing" class="dataTables_processing" style="display: none;">Processing...</div>
        // place where <div class="addButton"> should appear
        <div id="PositionDataTable2_filter" class="dataTables_filter"></div>
        <div class="dataTables_paginate paging_simple_numbers" id="PositionDataTable2_paginate"></div>
    </div>
</div>

我想取第一个div,它有addButton类并放入div PositionDataTable2并将它放在处理和过滤器部分之间。但追加和前置仅在div开始或结束时进行。

如果有人建议如何正确放置它并制作副本或者我的按钮不会在数据表fndestroy上消失并重新创建,那就太棒了。

2 个答案:

答案 0 :(得分:1)

您可以尝试使用$.after()插件,例如:

$(".dataTables_processing").after($(".addButton").html());

答案 1 :(得分:0)

Jquerys insertAfter()应该可以工作。 尝试这样的事情:

use 5.014;
use warnings;

my $file1 = '/path/to/file1';
my $file2 = '/path/to/file2';

#Open files
open my $fh1 , '<', $file1 or die $!;
open my $fh2, '<', $file2 or die $!;


#Read file1
my %gene_hash;
while(<$fh1>){
    chomp;
    my @arr = split; 
    next if $arr[0] eq "space";
    next if $arr[6] eq 'NA';

    my $key = $arr[5]; #Hash key

    my @snps = split /;/, $arr[6]; #to be used as value in hash
    my $first_snp = shift @snps; #remove 1st element from start

    my @first_snp = split /"/, $first_snp; #remove " from start
    unshift @snps, $first_snp[1]; #add 1st element back to beginning


    my $last_snp = pop @snps; #remove last element
    my @last_snp = split /"/, $last_snp; #remove " from end

    push @snps, $last_snp[0];# add last element back to the end
    push @snps, $arr[6] if $arr[6] =~/^rs.*/; #add element even if there are no "" eg SLC35E2B

    push @{ $gene_hash{$key} }, @snps; #assign values to hash
}



my %dmr_hash;
while(<$fh2>){
   chomp;
   my @arr = split;

   next if $arr[0] eq "space";
   next if $arr[6] eq 'NA';

   my $key = $arr[5]; #Hash key

   my @snps = split /;/, $arr[6];#to be used as value in hash
   push @{ $dmr_hash{$key} }, @snps; #assign values to hash

}  

编辑:如果你不想让第一个addButton消失,你可以使用.clone()

search