解决JQuery中$符冲突

来源:互联网 发布:流星网络电视 破解 编辑:程序博客网 时间:2024/06/15 09:32

报错:TypeError: $(…) is null。

解决办法:

1. 直接不使用$,使用JQuery

<script type="text/javascript">      jQuery(function(){          alert("jquery获取文本框值:"+jQuery('#test').val());  });  

2. jQuery.noConflict();自定义别名

var $j = jQuery.noConflict();// Use jQuery via $j(...)$j(document).ready(function () {  var secondary = $j("#secondary-footer");  secondary.hide().addClass("fixed").fadeIn("fast");  $j(window).scroll(function () {    if (secondary.offset().top >= ($j(document).height() - 350)) {      secondary.removeClass("fixed");    } else if (secondary + ":not('.fixed')") {      secondary.addClass("fixed");    }  });});

参考网址:There

0 0
原创粉丝点击