jquery and javascripts toghether
I have this 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>
and this 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);
});
and i need them in the same php.
I tried the following, but does not work.
<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&g开发者_Go百科t;
I do not see why you cannot keep these in separate files, just change your onload to 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);
});
why dont you put both of them in the onload
event handler.
精彩评论