jQuery:从输入数组获取价值

编程入门 行业动态 更新时间:2024-10-27 00:36:08
本文介绍了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:从输入数组获取价值

本文发布于:2023-10-12 02:52:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483542.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   价值   jQuery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!