jQuery check if attr = value

后端 未结 2 1685
半阙折子戏
半阙折子戏 2020-12-13 12:28

I seem to be having trouble with my code. I need to say:

if ( $(\'html\').attr(\'lang\').val() == \'fr-FR\' ) {
    // do this
} else {
    // do that
}
         


        
2条回答
  •  醉酒成梦
    2020-12-13 13:19

    Just remove the .val(). Like:

    if ( $('html').attr('lang') == 'fr-FR' ) {
        // do this
    } else {
        // do that
    }
    

提交回复
热议问题