开发者

jquery and javascripts toghether

开发者 https://www.devze.com 2023-03-09 23:59 出处:网络
I have this jquery.. <script type=\'text/javascript\'> $(document).ready(function() { $(\'.colnews2\').hide();

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消