我有一个页面,其中有一个html表,它使用tablesorter并在加载时进行排序。我希望我的dom解析器脚本只有在对该表进行排序后才能从该表中获取行。现在它正在跳过排序并抓取之前的行。
使用sortEnd事件
$(document).ready(function() {
// call the tablesorter plugin, the magic happens in the markup
$("table").tablesorter();
//assign the sortStart event
$("table").bind("sortStart",function() {
// Do stuff when the sorting begin
}).bind("sortEnd",function() {
// To stuff when the sorting ends
});
});
如果您在Javascript中使用DOM Parser,请尝试将defer="defer"
属性添加到Javascript的标记中。
如果您使用的是PHP中的函数,那么您可以根据需要多次调用函数sleep()
。
您也可以尝试制作某种数据属性标志,比如在完成排序事件时,在php开始解析之前,检查一下,如果它真的可以通过检查这个标志来完成,如果不能,请再次等待,稍后再试。