我有这个jquery ..
<script type='text/javascript'>
$(document).ready(function() {
$('.colnews2').hide();
$("#colnews1 li").click(function() {
//alert($(this).attr("id"));
$('.colnews2').hide();
var value = $(this).attr("id");
var theDiv = $("#colnews2-" + value);
theDiv.slideDown();
colnews1ID=value;
});
});
</script>
和这个javascripts ..
var pager = new Imtech.Pager();
$(document).onload(function() {
pager.paragraphsPerPage = 2; // set amount elements per page
pager.pagingContainer = $('#mainlevel-nav'); // set of main container
pager.paragraphs = $('div', pager.pagingContainer); // set of required containers
pager.showPage(1);
});
我在同一个php中需要它们。
我尝试了以下操作,但无效。
<script type='text/javascript'>
$(document).ready(function() {
var pager = new Imtech.Pager();
pager.paragraphsPerPage = 2; // set amount elements per page
pager.pagingContainer = $('#mainlevel-nav'); // set of main container
pager.paragraphs = $('div', pager.pagingContainer); // set of required containers
pager.showPage(1);
$('.colnews2').hide();
$("#colnews1 li").click(function() {
//alert($(this).attr("id"));
$('.colnews2').hide();
var value = $(this).attr("id");
var theDiv = $("#colnews2-" + value);
theDiv.slideDown();
colnews1ID=value;
});
});
</script>
答案 0 :(得分:0)
我不明白为什么你不能将它们保存在单独的文件中,只需将你的onload改为ready:
<script type='text/javascript'>
$(document).ready(function() {
$('.colnews2').hide();
$("#colnews1 li").click(function() {
//alert($(this).attr("id"));
$('.colnews2').hide();
var value = $(this).attr("id");
var theDiv = $("#colnews2-" + value);
theDiv.slideDown();
colnews1ID=value;
});
});
</script>
var pager = new Imtech.Pager();
$(document).ready(function() {
pager.paragraphsPerPage = 2; // set amount elements per page
pager.pagingContainer = $('#mainlevel-nav'); // set of main container
pager.paragraphs = $('div', pager.pagingContainer); // set of required containers
pager.showPage(1);
});
答案 1 :(得分:0)
为什么不把它们都放在onload
事件处理程序中。