我有一個輸入按鈕:識別jQuery的按一下按鈕在php行
while ($row = $result->fetch()) {
echo '<table class="cart-row" cellspacing="0" cellpadding="0" width="100%">';
echo '<tbody>';
echo '<tr>';
echo '<td width="75"><img border="0" width="59px" height="78px" title="" alt="" src=' . $row["ImagePath"] .'></td>';
echo '<td width="203"><span id="itemName" class="itemElements">'. $row["Name"] .'</span></td>';
echo '<td width="135"><span id="qtyNum">('. $row["Qty"] .')</span> <br />';
echo '<span id="qtyRemoveLink"><input class="linkbtn" type="submit" id="btnRemove" value="Remove"></td>';
echo '<td width="180"><span id="orderStatus" class="itemElements">In Stock Usually dispatched within 24 hours</span></td>';
echo '<td width="175" id="itemPriceRow"><span id="itemPrice">€ '. $row["Price"] .'</span></td>';
echo '</tr>';
echo '</tbody>';
echo '</table>';
echo '<br>';
}
我試圖用這個方法來觸發按鈕時,不過點擊事件只被解僱的事件在第一行中生成第一個按鈕。我正在使用此方法:
$(document).ready(function() {
$('#btnRemove').click(function() {
alert("test");
});
});
任何想法如何解決此問題?我知道在C#中有行數據綁定方法,但是在jQuery中我現在不存在如果它存在。謝謝
正如在下面的評論中提到的 - 你在所有地方使用的ID不正確。這對您的特定情況造成了問題,但您還需要更新所有標記以正確使用ID(或實際上,不使用ID)。 – 2011-12-21 21:23:08