Javascript/jQuery onclick not working

前端 未结 4 1177
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 01:09

i made a test.html document to test a script. Somehow it is not working and i can\'t get why nothing is happening. The Script is in -tags and wrapped with -tag and the css a

4条回答
  •  没有蜡笔的小新
    2020-12-02 01:23

    Your code is fine. Just wrap it in DOM ready and you are good to go.

    $(document).ready(function(){
        $('#menu li a').on('click', function() {
            $('li a.current').removeClass('current');
            $(this).addClass('current');
        });
    })
    

提交回复
热议问题