<script>
function edit(elem)
{
var ele=$(elem).siblings('label#test').html();
var a=document.getElementById('test');
var htm = '<input type="text" name="modal" id="modal" style="width:70%;" value="'+$(elem).siblings('label#test').html();+'"/>';
$dialog.html(htm)
.dialog({
autoOpen: true,
position: 'center' ,
title: 'EDIT',
draggable: false,
width : 300,
height : 40,
resizable : false,
modal : true,
buttons: { "Save" : function() { if($('#modal').val() != ''){a.value=$('#modal').val();$dialog.dialog('close');} else {alert('i++'+$('#modal').val()+'++');} } }
});
$dialog.dialog('open');
}
$(document).ready(function() {
var flag=0;
$("input:radio[@name=template]").click(function() {
var checkedoption = $(this).val();
if (checkedoption == "template3")
{
if (flag == 0)
{
var html = '<input type="text" name="val" id="val" /> <input type="button" value="Add" id="add"><br>';
$('#useroptions').append(html);
flag=1;
$('#add').click(function(){
var a = $('#val').val();
if (a == '')
{
alert('Enter options');
}
else
{
var section= '<tr class="clickable"><td id="userval" BGCOLOR="#FF6699"><label id="test">' + a + '</label> <IMG SRC="/media/img/chunkedit.gif" onclick="javascript:edit(this);" > <IMG SRC="/media/img/close.gif" onclick="javascript:remove(this);" ></td></tr>';
$('#useroptions').append(section);
}
});
}
}
});
});
</script>
<form>
<table>
<tr><td>
<div id="useroptions"></div>
</tr></td>
</table>
</form>
如何在上面的代碼測試設置一個新值.. 感謝通過jQuery的設置值
實驗室el元素不包含表單控件,並且沒有for屬性。你確定你使用正確嗎? http://www.w3.org/TR/html4/interact/forms.html#h-17.9.1 – Quentin 2010-03-23 14:47:12