這裏是我想要轉換的代碼:轉換功能,jQuery的點擊()調用
<script>
function fsomething(rowid) {
window.location = "/somewhere/" + rowid;
}
</script>
<tr>
<td>
<button onClick="fsomething('{{rowid}}')">row 1L</button>
</td>
<td>
<button onClick="fsomething('{{rowid}}')">row 2L</button>
</td>
</tr>
我怎樣才能將它轉換爲:
$('button').click(function() { .... });
其中動態生成{{rowid}}
,並且每行都獨一無二?
你想如何從td獲取行ID? – Dogbert
什麼生成HTML,這是一個jQuery模板,PHP,...?如果你可以把你的html輸出改成''button data-rowId =「{{rowid}}」'這會很容易。 –
任何你不能使用''或類似的理由? JS禁用的用戶無法以您的方式使用您的網站。 – Lekensteyn