jQuery: unrecognized expression

后端 未结 2 1537
忘掉有多难
忘掉有多难 2021-01-18 02:19
$(document).ready(function(){

    var page = window.location.hash;
    if(page != \"\"){
        $(\'a[href=\'+ page +\']\').addclass(\'selected\');
        pageloa         


        
2条回答
  •  天命终不由人
    2021-01-18 02:57

    Try this instead:

    $('a[href="'+ page +'"]').addClass('selected');
    

    (You need to escape the value of the href – with this, you get a[href="#/page/link"].)

提交回复
热议问题