jQuery 检查是否 attr = 值 [英] jQuery check if attr = value
本文介绍了jQuery 检查是否 attr = 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码似乎有问题.我要说:
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 = 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文