How to reach the element itself inside jQuery’s `val`?

Use the syntax that accepts a function as the parameter

$('.fillvalfromvar').val( function(){
   return pagedata[ this.id ];
});

(assuming that those input elements have the fillvalfromvar class)


or you could use the .each() method

$('.fillvalfromvar').each( function(){
   this.value = pagedata[ this.id ];
});

Leave a Comment

deneme bonusu veren sitelerbahis casino