Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get the value of the first td of the table using JQuery?
    primarykey
    data
    text
    <p>I have a table where in I have binded the values which are coming from the Form.In that form I have a primary key Field as TicketId which I have kept as hidden in the form and while inserting it into the table I am showing it.For Binding the data I have used Knockout.So I want to delete the row that I will select.So while selecting it I should get the id of that row so that I can passed it to the Delete action using ajax.But My problem is that I am not getting that id.So how to do this? My code:</p> <pre><code>&lt;table id="table2" style="border: double"&gt; &lt;thead&gt; &lt;tr&gt; &lt;td&gt;Ticket ID&lt;/td&gt; &lt;td&gt;Ticket Type&lt;/td&gt; &lt;td&gt;No of Tickets&lt;/td&gt; &lt;td&gt;Ticket Price&lt;/td&gt; &lt;td&gt;Start Date&lt;/td&gt; &lt;td&gt;End Date&lt;/td&gt; &lt;td&gt;Action&lt;/td&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;!--Iterate through an observableArray using foreach--&gt; &lt;tbody id="ticketid" data-bind="foreach:TicketDatas"&gt; &lt;tr style="border: solid" data-bind="click: $root.getselectedTicket" id="updtr"&gt; &lt;td id="rowid" data-bind="text:TicketId"&gt;@*&lt;span data-bind="text:No_Of_Ticket"&gt;&lt;/span&gt;*@&lt;/td&gt; &lt;td data-bind="text:SelectedTicketType"&gt;@*&lt;span data-bind="text:No_Of_Ticket"&gt;&lt;/span&gt;*@&lt;/td&gt; &lt;td data-bind="text:No_Of_Ticket"&gt;@*&lt;span data-bind="text:No_Of_Ticket"&gt;&lt;/span&gt;*@&lt;/td&gt; &lt;td data-bind="text:Ticket_Price"&gt;@*&lt;span data-bind="text:Ticket_Price"&gt;&lt;/span&gt;*@&lt;/td&gt; &lt;td data-bind="text:Start_Date"&gt;@*&lt;span data-bind="text:Start_Date"&gt;&lt;/span&gt;*@&lt;/td&gt; &lt;td data-bind="text:End_Date"&gt;@*&lt;span data-bind="text:End_Date"&gt;&lt;/span&gt;*@&lt;/td&gt; &lt;td&gt; &lt;button data-bind="click: $root.deleterec"&gt;Delete&lt;/button&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;script type="text/javasript"&gt; self.deleterec = function () { if (confirm('Are you sure to Delete this ticket ??')) { var tickid = $("#table2 tr:eq(0)").attr("id"); $.ajax({ type: "POST", data: { id: tickid }, url: "Ticket/DeleteTicket", //data: "{id:" + ko.toJSON(id) + "}", success: function (data) { self.TicketDatas.remove(data); alert("Record Deleted Successfully"); //GetTickets();//Refresh the Table }, error: function (error) { alert(error.status + "&lt;--and--&gt; " + error.statusText); } }); } }; &lt;/script&gt; </code></pre> <p>so just want the solution for this statement if I ask in short</p> <pre><code>var tickid = $("#table2 tr:eq(0)").attr("id"); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload