 <p>You missed last <code>}</code> braces for loop. You put <code>key</code> as string it need to concadinate with <code>+</code> symbol like the below code.</p> <pre><code> var data = { Name : "name", Price : 50 }; var modalId ='hai'; for(var key in data){ if (data.hasOwnProperty(key)) { console.log($('#'+modalId).find('input[name='+key+']')); console.log($('#'+modalId).find('textarea[name='+key+']')); console.log($('#'+modalId).find('select[name='+key+']')); } } </code></pre> <p><a href="http://jsfiddle.net/0ureckd0/" rel="nofollow"><strong>Fiddle</strong></a></p>