我有一個html按鈕,應該點擊按鈕點擊javascript。它識別按鈕單擊並顯示確認警報,但不會繼續併發布console.logs或轉到ajax方法。 這裏是SCRIPT關閉:Javascript not firing on button click
$('.Delete')
.click(function() {
return confirm("Are you sure you'd like to delete this entry?"
if(return = true)
{
var parent = $(this).parent().prev();
var tr = $(this).closest('tr');
var ValNode = tr.find(".typeText").first();
var AddrNode = parent.children(".AddrText").first();
var Val = ValNode.val();
var addr = addrNode.val();
console.log(Val);
console.log(addr);
var item = { Value: Val, Address: addr }
deleteItem(userID, item);
}
});
這是html元素,我認爲它可能與按鈕的元素它調用的關係做。我有他們作爲表親。
<asp:ListView runat="server" id="ListView1" >
<LayoutTemplate>
<thead>
<tr>
<th>
<a href="#">Type</a>
</th>
<th>
<a href="#">Address</a>
</th>
</tr>
</thead>
<tbody>
<tr id="itemPlaceholder" runat="server" />
</tbody>
<tfoot>
</tfoot>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<input type="text" id="Type" class="TypeText " value="<%# Eval("Type")%>" />
<input type="text" id="Addr" class="AddrText " value="<%# Eval("Address")%>" />
</td>
<td>
<input type="button" id="btn_update" class="Update" value="Update" />
<input type="button" id="btn_delete" class="Delete" value="Delete" />
</td>
</tr>
</ItemTemplate>
</asp:ListView>