开发者

is an element an input?

开发者 https://www.devze.com 2023-03-15 20:48 出处:网络
How can you check if an element is an input? if(elm.val() == null){ // is not an input } els开发者_运维知识库e{

How can you check if an element is an input?

if(elm.val() == null){
// is not an input
}
els开发者_运维知识库e{
// is an input
}


Well you know what element you are selecting.

or (if you really do not know) you can do:

if(elm.is('input')) {} //assuming elm is a jQuery element
else {}


You can use the is function to determine if an element is an input tag:

jQuery(elm).is("input");


//jquery    
if( $("#elementid").is("input") ){}
    else
    {}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号