Walrus
Walrus

Reputation: 20444

JQuery Update values by ID and similar id

I'm trying to update values of hidden fields with those of their similar inputs. I have missed something as it is not working. Here is the code.

function livecntupdate() {
    $('input').each(function(){
        $(this).val($('CNT' + this.id).val())
    });
}

Marvellous

Upvotes: 1

Views: 141

Answers (1)

Sarfraz
Sarfraz

Reputation: 382746

You are missing hash # there needed for the id:

function livecntupdate() {
    $('input').each(function(){
        $(this).val($('#CNT' + this.id).val())
    });
}

Upvotes: 1

Related Questions