I know should be really simple, but I just don’t get it.
I’m using clone to copy a <li> element:
var li = $('.selected_list .template').clone();
The list has the following items:
<li>
<input type="hidden" value="" class="item_id" name="item_id[]">
<div class="col_rating">
<input type="textbox" value="" maxlength="3" class="item_rating" name="">
</div>
</li>
I can use the following to change the content of the item_id input:
$(li).find('.item_id').prop({
'value': $(item).attr('id'),
'name': 'item_id[]'
});
$(li).find('.col_rating').find('input.col_rating').prop('name','item_rating[]');
$(li).find('.col_name').text($(item).find(('.assoc_name')).text());
$(li).find('.col_cost > input.item_cost').val($('.info_container .unit_cost').val());
But how can I change the value of the input that is wrapped inside the div?
I tried using > to access children, but that didn’t work.
You help is much appreciated 🙂
Update
I am able to change the value of the item_id. The question is, how do I update the name attribute of the col_rating input?
1 Answer