这是因为jquery不能自动执行$("XXX")函数解决办法:要么在函数方法里边执行$("XXX");要么这么写代码: $(document).ready(function() { $("XXX") }