jQuery selector by xlink

后端 未结 5 1779
执笔经年
执笔经年 2021-01-27 11:19
$(\'a[xlink\\\\:href=#coastline]\').attr(\'class\',\'grey\');
$(\'a[xlink\\\\:href=#onshore]\').attr(\'class\',\'blue-light\');

This is what I currentl

5条回答
  •  死守一世寂寞
    2021-01-27 11:44

    Maybe this is what you want Demo

    $('a').each(function(i){
        if($(this).attr('href') == "#coastline") $(this).addClass('gray');
        if($(this).attr('href') == "#onshore") $(this).addClass('green');
        if($(this).attr('href') == "") $(this).addClass('yello');
    });
    

提交回复
热议问题