开发者

Help to make jQuery simple

How can i make this shooter.

It does what it should but it is very long. Oh and I need to run a function for each number.

This is my HTML

<div id="moremenu" class="hide"&开发者_高级运维gt;
<ul>
<li>View count</li>
<li>Click count</li>
<li>Profile</li>
<li>Inbox</li>
<li>Uploads</li>
<li>TV</li>
<li>Notes</li>
<li>More</li>
</ul>
</div>
<div class="status"></div>

And this is my jQuery

    $("#moremenu ul li").click(function () {

    var index = $('#moremenu ul li').index(this);
    var clickval = $('#moremenu ul li').text(this);

    //$('.status').prepend('<p>click index was '+index+'</p>').fadeOut('fast').fadeIn('slow');
    if(index == 0){
        $('.status').prepend('<p>click index was '+index+'</p>').prepend('<p>You clicked '+clickval+'</p>').fadeOut('fast').fadeIn('slow');
    }
    if(index == 1){
        $('.status').prepend('<p>click index was '+index+'</p>').prepend('<p>You clicked '+clickval+'</p>').fadeOut('fast').fadeIn('slow');
    }
    if(index == 2){
        $('.status').prepend('<p>click index was '+index+'</p>').prepend('<p>You clicked '+clickval+'</p>').fadeOut('fast').fadeIn('slow');
    }
    if(index == 3){
        $('.status').prepend('<p>click index was '+index+'</p>').prepend('<p>You clicked '+clickval+'</p>').fadeOut('fast').fadeIn('slow');
    }
    if(index == 4){
        $('.status').prepend('<p>click index was '+index+'</p>').prepend('<p>You clicked '+clickval+'</p>').fadeOut('fast').fadeIn('slow');
    }
    if(index == 5){
        $('.status').prepend('<p>click index was '+index+'</p>').prepend('<p>You clicked '+clickval+'</p>').fadeOut('fast').fadeIn('slow');
    }
    if(index == 6){
        $('.status').prepend('<p>click index was '+index+'</p>').prepend('<p>You clicked '+clickval+'</p>').fadeOut('fast').fadeIn('slow');
    }
    if(index == 7){
        $('.status').prepend('<p>click index was '+index+'</p>').prepend('<p>You clicked '+clickval+'</p>').fadeOut('fast').fadeIn('slow');
    }
    if(index == 8){
        $('.status').prepend('<p>click index was '+index+'</p>').prepend('<p>You clicked '+clickval+'</p>').fadeOut('fast').fadeIn('slow');
    }
});


var index = $('#moremenu ul li').index(this);
var clickval = $('#moremenu ul li').text(this);

if(index >= 0 && index <= 8){
    $('.status').prepend('<p>click index was '+index+'</p>').prepend('<p>You clicked '+clickval+'</p>').fadeOut('fast').fadeIn('slow');
}

This is simple JavaScript.


    var index = $('#moremenu ul li').index(this);
    var clickval = $('#moremenu ul li').text(this);

    if(index >= 0 && index <= 8){
       $('.status').prepend('<p>click index was '+index+'</p>').prepend('<p>You clicked '+clickval+'</p>').fadeOut('fast').fadeIn('slow');
    }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜