报错: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