首页 > 解决方案 > 数据表响应函数触发时如何重做js

问题描述

我想对表格做一些js函数,就像

var table = $('#example').DataTable({
    responsive: true,
});

$(".point").html('hello');

但是当窗口调整大小和响应功能工作时,它不能重做 js 功能。

即使我使用

table.on( 'draw', function () {
  console.log( 'Redraw occurred at: '+new Date().getTime() );
  $(".point").html('hello');
} );

仍然无法重做js。响应式触发时如何触发功能重做?

https://jsfiddle.net/housekeepings/v8x9wn03/34/

标签: javascripttriggersdatatablesresponsive

解决方案


我认为您应该使用窗口调整大小事件:

$(window).on('resize', function(){
    console.log( 'Redraw occurred at: '+new Date().getTime() );
    $(".point").html('hello'); 
});

推荐阅读