jQuery检查attr = value [英] jQuery check if attr = value

查看:101
本文介绍了jQuery检查attr = value的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎遇到了代码问题。我需要说:

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
}

当我检查控制台时,我只是得到一个错误,告诉我这不是一个功能。帮助将不胜感激。

When I check the console, I just get an error telling me this isn't a function. Help would be appreciated.

谢谢,

推荐答案

只需删除.VAL()。喜欢:

Just remove the .val(). Like:

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

这篇关于jQuery检查attr = value的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆