jQuery确定页面上是否存在元素 [英] jQuery determining if element exists on page
本文介绍了jQuery确定页面上是否存在元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何确定页面上是否存在元素...例如
How can I determine if an element exists on a page... for instance...
$('select[name="modifier_option"]')
如果屏幕上存在该选择框,我需要在页面上验证它的值以确保其值> 0,但是如果不存在,则无需担心.
If that select box exists on the screen I need to validate it's value on the page to ensure it's value is > 0, but if it doesn't exist I don't need to worry about it.
推荐答案
if( $('select[name="modifier_option"]').length )
{
// it exists
}
这篇关于jQuery确定页面上是否存在元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文