二次查询时 jQuery 失灵的问题

一个透过 .prepend 或者 .text 做更新的页面中,有时候在检索第二次的时候 $(‘#fool’) 选择器 会提示:

“TypeError: undefined is not a function”

此问题通常是由于引用多个 js 库相互冲突导致的,解决的办法是把 $(‘#fool’) 换成 jQuery(‘#fool’) 。

Comments

One response to “二次查询时 jQuery 失灵的问题”

  1. oopus Avatar
    oopus

    方案二:
    在使用 $ 之前先声明:
    var $ =jQuery.noConflict();

Leave a Reply

Your email address will not be published. Required fields are marked *