问题描述
我需要在选中复选框时获取该功能中的texbox值
我尝试过:
< table>
<?php foreach($ list_points as $ points):
$ i = 1; ?>
< tr class =gradeA>
< td><?php echo $ points ['vehiclename'] ?>< / td>
< td>< input type =textname =ptimeid =ptime-text<?php echo $ i;?> class =ptime-text>< / td>
< td>
< div class =i-checks ptime-check& gt;
< label>
< input type = checkboxvalue =target =ptime-text<?php echo $ i;?> class =testonclick =check_ptime();> < I>< / I>
< / label>
< / div>
< / td>
< / tr>
<?php $ i ++; endforeach; ?>
< / table>
我的剧本功能是
function check_ptime()
{
alert($(this).parent()。parent()。parent()。 parent()。find('。ptime-text')。val()); //这里我需要thextbox的值
}
i need to get the texbox value in the function when checking the checkbox
What I have tried:
<table>
<?php foreach ($list_points as $points):
$i=1; ?>
<tr class="gradeA">
<td><?php echo $points['vehiclename'] ?></td>
<td><input type="text" name="ptime" id="ptime-text<?php echo $i; ?>" class="ptime-text"></td>
<td>
<div class="i-checks ptime-check">
<label>
<input type="checkbox" value="" target="ptime-text<?php echo $i; ?>" class="test" onclick="check_ptime();"> <i></i>
</label>
</div>
</td>
</tr>
<?php $i++;endforeach; ?>
</table>
my script function is
function check_ptime()
{
alert($(this).parent().parent().parent().parent().find('.ptime-text').val());//here i need the value of thextbox
}
推荐答案
这篇关于使用jquery选中复选框时获取文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!