jQuery的值未定义 [英] value undefined for jquery

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

问题描述

这是我的jQuery

here is my jquery

 var obj=$("#Connect");
  alert($("#Connect").value);

该值似乎是未定义的,但是我在那里有一个html标记

The value appeared to be undefined, but I have a html tag there

<input type="button" id="Connect" value="Connect"/>

出什么问题了?

推荐答案

您正在此处混合使用jquery和javascript ...在jquery中获取值的正确方法是val()

you are mixing jquery and javascript here...correct way to get value in jquery is val()

尝试

jquery

alert($("#Connect").val());

javascript

 alert(document.getElementById("Connect").value);

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

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