javascript - jQuery can't access input field in table -


i'm trying change input field value dynamically loaded html. however, can't seem find right code.

here code using:

$.get('/js/dynamic/locations', function(newrow) {     var existing_elem = $('.edit-table tr:last').after(newrow);      var appendedrow = $('table tr:last-of-type');     appendedrow.find('td[data-th="name"] > span').text(v.location_name);     appendedrow.find('td[data-th="name"] > input').val(v.location_name); }); 

the span text updating correctly, input value not updating @ all.

here value of newrow:

<tr>   <td data-th="name">     <span class="edit-input-text"></span>     <input class="inp input-edit" type="text" name="location_name" value="">   </td>   <td data-th="address"><span class="edit-input-text"></span>     <input class="inp input-edit" type="text" name="address" value="">   </td> </tr> 

based on html structure , code can tell sure it's fine , input value indeed updated.

the reason confusion have lays in difference between properties , attributes. not same. how test input value has changed?

because viewing source in firebug. span gets updated input value not.

you need upderstand since updating input val method - setting input value property, not attribute. attributes not going change unless update directly setattribute method (attr in jquery).


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -