单击链接时单击“事件”两次

时间:2012-02-03 13:42:01

标签: javascript jquery

每当我点击链接时,都会触发我的点击事件 这是我的javascript代码

$('#switchnavigation').click(function(e){
    console.log('->'+i);i++;
    //var x=$('#switches').html();
            if(i<2)
    {
        $('#switchnavigation').append('<ul id="navig"><li class="ui-btn-inner ui-li" style="line-height:20px;padding-left:30px;">Apps</li><li class="ui-btn-inner ui-li" style="line-height:20px;padding-left:30px;">Videos</li></ul>');
        e.stopPropagation();console.log(i);
        a=setTimeout(rm,3000);

    }
    else
    {
        $('#navig').remove();
        i=0;
    }

    function rm()    
    {
        $('#navig').remove();
        i=0;
        clearTimeout(a);
    }

    e.stopPropagation();
});

和各自的HTML代码

<a href="#" data-theme="g" id="switchnavigation"  data-role="button" class="revise-menus custom-b ui-btn ui-btn-icon-left ui-btn-corner-all ui-shadow ui-btn-up-e" data-ajax="false" data-icon="back">
    <span class="ui-btn-inner ui-btn-corner-all" aria-hidden="true">
    <span class="ui-btn-text" id="switches">Books</span>
    </span>
</a>

0 个答案:

没有答案