如何使用jquery访问隐藏字段值

时间:2016-05-20 07:24:36

标签: php jquery html5

我有一个手风琴表,我希望使用Jquery和checkboxes获取行id值。为了使事情变得更容易我使用隐藏值字段。当我尝试做隐藏输入id总是设置为最后一行值而是给了我所有的价值观。

我的手风琴表innerHTML就像这样

<div id="acc22" class="accBox">
<p class="accordianHead">
<div class="accordianBody">
<form id="form_22" action="" method="post" encoding="">
<div style="display:none;">
<table id="item_tbl_22" class="accTable" cellspacing="0" cellpadding="0" border="0" width="100%">
<thead class="greyBg paddingHead">
<tbody>
<input id="cloth_id22" type="hidden" value="72" name="fabric_id">
<input id="cloth_colour_id22" type="hidden" value="824" name="data[Cloth][cloth_id]">
<tr id="S3639-1-1_824" style=" ">
<tr id="S3639-1-2_824" style=" ">
<tr id="S3639-1-3_824" style=" ">

<tr>
</tbody>
</table>
</form>
</div>

这是我的隐藏ID

 <input type="hidden" id="form_te[<?php echo  $id;?>]" value="<?php echo  $tbl_content;?>" />

这是我的Jquery方法

 $("input[name='s_i_width[]']:checked").each(function(event) {

printArray.push($('#form_te'+ this.value).val());
  console.log($('#form_te'+ this.value).val());

如何存档?

2 个答案:

答案 0 :(得分:0)

很抱歉,我认为特殊字符需要添加额外的代码。 试试这个。

$("#form_te\\["+<?php echo  $id;?>+"\\]").val()

感谢这些家伙。 Find DOM element by ID when ID contains square brackets?

答案 1 :(得分:-1)

你试过吗

$('#form_te['+<?php echo  $id;?>+']').val()