我在WordPress网站上制作了一个示例表。
intersperse
但是,我正在尝试使用jQuery在此特定页面上使用帖子ID 2977对此表进行实时过滤搜索。我已将wp_enqueue函数添加到WordPress中的functions.php代码的底部。
`<input id="search" class="text" type="text" placeholder="type text" ><table><tbody><tr>
<td>George</td>
<td>Washington</td>
<td>Virginia</td>
</tr><tr>
<td>Benjamin</td>
<td>Franklin</td>
<td>Philadelphia</td>
</tr><tr>
<td>Thomas</td>
<td>Jefferson</td>
<td>Virginia</td>
</tr></tbody></table>`
custom_scripts.js文件如下所示:
add_action( 'wp_enqueue_scripts', 'custom_scripts' );
function custom_scripts() {
if (is_page(2977)){
wp_enqueue_script('custom_scripts', get_template_directory_uri().'/js/custom_scripts.js', array('jquery'));
}
}
来自http://jsfiddle.net/9hGym/293/ 的jQuery代码
我重复尝试过这段代码,但表格从不过滤掉。如果有人可以指出我出错的地方以及原因,那就太好了。