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 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题