javascript - Removing entire html tags in datatables row grouping -
i have html output using datatable row grouping take data table , unfortunately table cell this:
15.000 <i class="fa fa-caret-square-o-down fa-fw text-red" data-toggle="tooltip" data-placement="right" title="decrease 10.000 "></i>
and want 15000
output only. how preg_replace
?
i have tried /[^\d]/g
there result 1500010000
remove tags , combine numbers.
i tried /<i>(.*?)<\/i>/
not working. how can remove javascript?
so here rowgroup code
rowgroup:{ endrender:function(rows,group){ var nomor = []; (i = 9; < 31; i++){ nomor.push(i); } return $('<tr/>') .append( '<td></td>' ) .append( '<td colspan="5" class="tdtotal text-right">total '+group+'</td>' ) .append( $.map(nomor, function(value,key){ var ttl=rows .data() .pluck(value) .reduce(function(a,b){ return + b.replace(/[^\d]/g,'')*1; },0); return $( '<td class="bg-aqua disabled color-palette text-right" >'+$.fn.datatable.render.number('.', ',', 0,).display( math.abs(ttl) )+'</td>'); })) .append( '<td colspan="2" class="bg-aqua disabled color-palette "> </td>' ); }, datasrc: '0' }
i'm not clear question. can take output below
var string = '15.000 <i class="fa fa-caret-square-o-down fa-fw text-red" data-toggle="tooltip" data-placement="right" title="decrease 10.000 "></i>'; $('button').click(function(){ alert(string.split(' ')[0]); })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button>click</button>
Comments
Post a Comment