dongyan3237 2015-07-01 05:03
浏览 201

使用jquery在循环内获取特定的文本框值

I have a problem to get particular textbox value inside a loop using jquery. please see the below code. I will get 1 to 10 values all the textbox next to print the button. when I submit that particular textbox value, it will always coming that first value as "1".

I know in jquet code I have to put "$this" key word to get that particular value, but I am new to jquery and I tried so many methods to do that, I failed. please help.

<?PHP for($i=0, $i<10; $i++) ?>
<input type="text" name="ad_id" value="<?PHP echo $i; ?>" class="ad_id" />
<button type="button" class="ad_increase">Submit</button>
<?PHP } ?>


<script>
$('.ad_increase').click(function() {
    var get_ad_id = $('.ad_id').each();


    $.post('includes/show_ad_id.php', {
        ad_id: get_ad_id
    }, function(res) {

        if (res != 1) {
            $('.display_in_model').html(res);
        } else {
            $('.display_in_model').html('');
        }

    });

});
</script>
  • 写回答

2条回答 默认 最新

  • dqb14659 2015-07-01 05:09
    关注

    Try

    $(".ad_id").each(function() {
        alert($(this).val());
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)