I need to add in the object Select
o Id
and Texto
from this function:
//Adiciono o item retirado da table html para o objeto html Select
$.each(_arrDescricao, function (text, key) {
var option = new Option(key, text);
$('.selListaItem').append($(option));
});
The problem is that I can only add text
, how do I add Id
to Select
? Home
This is the complete code:
$(document).on("click", ".btnRemoverItem", function (e) {
e.preventDefault();
var _arrId = new Array();
var _arrDescricao = new Array();
$("#tableHtml tbody").find('input[type="checkbox"]').each(function () {
if ($(this).is(":checked")) {
var _id = $(this).closest('tr').find('td[data-id]').data('id');
var _descricao = $(this).closest('tr').find('td[data-descricao]').data('descricao');
$(this).closest('tr').remove();
_arrId.push(_id);
_arrDescricao.push(_descricao);
};
});
//Adiciono o item retirado da table html para o objeto html Select
$.each(_arrDescricao, function (text, key) {
var option = new Option(key, text);
$('.selListaItem').append($(option));
});
});