0
我想動態添加一個我的輸入字段值與jQuery。但傳遞的值不會附加到目標上。我的代碼如下,因爲它遵循jquery將附加值添加到輸入字段
//on click popup modal with a form
$(document).on('click', '#form', function(e) {
e.preventDefault();
$('<div></div>').load($(this).attr('href')).dialog({
title: $(this).attr('title'),
//autoOpen: false,
modal: true,
draggable: true,
width:900,
position: ['top',50],
close: function(event, ui)
{
$(this).dialog('destroy').remove()
}
});
//this value should be appended to one of the input field, the value exists on alert but is not getting appended
$('input#inputPrepend cashback').val($(this).closest('tr').children('td.cashback').text());
});
注:
//this value is picked up from my Jquery Datatable clicked row
$(this).closest('tr').children('td.cashback').text()
//this input field is getting created inside of modal
$('input#inputPrepend cashback')
HTML
<div class="formRow fluid">
<span class="grid12">
<span class="grid2"><label class="form">Cashback</label></span>
<span class="grid3">
<div class="input-prepend">
<span class="add-on">€</span>
<input style="width:120px;height:30px; position relative; top:-10px"type="text" id="inputPrepend cashback" type="text" readonly="readonly" value="" />
</div>
</span>
</span>
</div>
感謝您的反饋意見。我一直在嘗試,但似乎沒有工作。 – kakuki 2013-04-25 13:56:08