未定义属性的jQuery长度 [英] Jquery length of attribute undefined

查看:29
本文介绍了未定义属性的jQuery长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查属性中字符串的长度?这显示未定义"值:

How can I check the lenght of the string that is in the attribute?This shows 'undefined' value:

var action = $(obj).closest("form").attr('action');
警报(动作.长度);

推荐答案

你的拼写有点不对,.lenght 应该是 .length:

Your spelling is just a bit off, .lenght should be .length:

var action = $(obj).closest("form").attr('action');
alert(action.length);

这篇关于未定义属性的jQuery长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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