我正在尝试从页面中删除一个div(最好是防止它加载)但是现在我正在解决页面加载后删除它。
我在jsfiddle上尝试了这些代码行,它可以工作。并删除'#content_gallery'div。
<script type='text/javascript'>
$(document).ready(function(){$('#content_gallery').remove();});
</script>
但是当我将它应用到我的测试网站的头上时。它不会删除指定id的div。我也尝试用其他id标签删除其他div
测试网站:http://stage.bravo-company.info/luchatest/category/gallery/
我也试过了:
$(document).ready(function(){
$('#content').remove();
});
和
$(function(){
$('#content_gallery').remove();
});
任何想法?这可能是jquery冲突的一个例子吗?我不知道如何确认这一点。
这是测试网站:http://stage.bravo-company.info/luchatest/category/gallery/
答案 0 :(得分:3)
另一个JavaScript库与您网站上的jQuery
冲突。解决此问题的正确方法是使用jQuery.noConflict
。
<script type="text/javascript" src="other_lib.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$.noConflict();
jQuery(document).ready(function($) {
// Code that uses jQuery's $ can follow here.
$(function(){
$('#content_gallery').remove();
});
});
// Code that uses other library's $ can follow here.
</script>
答案 1 :(得分:0)
这是案件冲突
使用
jquery(document).ready(function(){jquery('#content_gallery').remove();});