本文介绍了jQuery:从输入数组获取价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们采用以下形式:
<form> ... <table width="100%" cellspacing="0" class="datagrid_ppal"> <tbody> <tr> <th scope="row">Area 1 <input name="config_line" type="hidden" value="0,5,50" /></th> <td class="gantt"> </td> <td class="gantt"> </td> <td class="gantt"> </td> ... </tr> </tbody> </table width="100%" cellspacing="0" class="datagrid_ppal"> ... <form>我们需要从隐藏的输入值中获取第一个,第二个或第三个.我们已经尝试过了,但是没有用:
What we need is to get the first, second or third from the hidden input value. We have tried this and didn't work:
var value = $('th').children('input:hidden').val();有人可以帮助我们吗?我们真的很感激.
Can anyone help us? We would really appreciate it.
推荐答案隐藏字段的值不是数组,而只是字符串:"0,5,50".
The value of your hidden field is not an array, but just the string: "0,5,50".
要使用jQuery检索该值,请使用:
To retrieve that value using jQuery use:
$('input[name=config_line]').val()要将该字符串拆分为数组,请使用split()方法.
To split that string into an array use the split() method.
组合:
var firstValue = $('input[name=config_line]').val().split(",")[0]; // etc...更多推荐
jQuery:从输入数组获取价值
发布评论