var rName = ''; if(rName){ $("input[name='lName']").attr('id','rName'); $("input[name='lName']").val(''); }