我正在將數據從'table_source'移動到'table_dest',但'table_source'使用中繼器創建並正確創建動態表ID。但是,我需要使id =「table_sourceX」的元素在jquery函數更改中更改(即table_source0變爲table_source1)。我只是學習jQuery和知道這是世界你好聲明的東西,但在這裏有雲:動態更改jquery
jQuery的
//moves from source to destination table
//$("#table_source").on('click', 'img.move-row', function (e) {
var tableName = "#table_source" + repCounter.ToString()
$(tableName).click(function (e) {
alert(tableName)
var tr = $(this).closest("tr").remove().clone();
tr.find("img.move-row")
.attr("src", "remove_image_path.jpg")
.attr("alt", "Remove");
$("#table_dest tbody").append(tr);
});
//moves from destination back to source
$("#table_dest").on('click', 'img.move-row', function (e) {
var tr = $(this).closest("tr").remove().clone();
tr.find("img.move-row")
.attr("src", "images/add.png")
.attr("alt", "Move");
$("#table_source tbody").append(tr);
});
C#
public int repCounter= 0;
public string renderItem(RepeaterItem item)
{
object DI = item.DataItem;
string MyVal = DataBinder.Eval(DI, "FirstName").ToString();
string html = String.Empty;
html = "<table id=" + "table_source" + repCounter.ToString() + " style=border: 1px solid black;border-collapse: separate;" +
"border-spacing: 10px 50px;>" +
"<tr>" +
"<td>" + MyVal + "</td><td><img alt='Move' class='move-row'id='arrowRotate' src='images/add.png' data-swap='images/minussymbol.jpg'/></td>" +
"</tr>" +
"</table>";
repCounter++;
return html;
}
我試圖清理我的意思是使用示例的細節。 –
嗨,這行是爲什麼'//$("#table_source").on('click','img.move-row',函數(e){'?是不必要的行? –
你想要將一個'