码迷,mamicode.com
首页 > Web开发 > 详细

jQuery取得select选中的值

时间:2014-06-26 19:42:55      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:class   java   ext   com   string      

记录一下。

本来以为$("#vitNeedreply").val();是取得选中的值,

那么$("#vitNeedreply").text();就是取得的文本。

alert($("#vitNeedreply").val());出来的值是正确的

但实际上$("#vitNeedreply").val();取得的是一个Object,是一个数组。要是直接用这个值的话,有些地方会报类型不匹配(如mybits里的XXquery.java里的属性值要是String,那就对不上这个值,会报错

org.springframework.beans.InvalidPropertyException: Invalid property ‘vitNeedreply[]‘ of bean class [com.ces.petition.query.RoleAccessQuery]: Property referenced in indexed property path ‘vitNeedreply[]‘ is neither an array nor a List nor a Map; returned value was [001]

所以这是不正确的,正确做法是:

jQuery("#vitNeedreply option:selected").val();

这样才能取得一个值

 

jQuery取得select选中的值,布布扣,bubuko.com

jQuery取得select选中的值

标签:class   java   ext   com   string      

原文地址:http://www.cnblogs.com/lyf22/p/3808279.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!