jQuery get the input value in an .each loop

若如初见. 提交于 2019-12-01 16:30:26

You can use this to access the current element in the loop:

valu = $(this).val();

The current element is also sent as a parameter to the callback function, so you can pick it up:

.each(function(index, elem) {

Then use the parameter:

valu = $(elem).val();
$('.custemb, input[name=cb], input[class=multadd]').live("click", function() {

    $('input[class=multadd]:checked').each(function(index) {
        var $this = $(this);
        val = index + 2;
        valu = $this.val();
        multiz = multiz + '&aid' + val + '=' + valu;
    });
});

Use this to find the control that was clicked

$('input[class=multadd]:checked').each(function(index) {
        val = index + 2;
        valu = $(this).val();
        multiz = multiz + '&aid' + val + '=' + valu;
    });
sadam
var texts= $(".class_name").map(function() {
    return $(this).val();         
}).get();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!