Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery traversing table elements
    primarykey
    data
    text
    <p>I am using Jquery to dynamically populate the table element. My table will have three columns - Label, textarea and a button. I am binding a click event on click of the button. Below is my Jquery code.</p> <pre><code>var rowElem = $('&lt;tr id="'+ key + '" class="queryRow"&gt; &lt;/tr&gt;'); rowElem.append($('&lt;td class="queryTitleCol"&gt;' + key + '&lt;/td&gt;')); var colElem = $('&lt;td class="queryValueCol"&gt;&lt;/td&gt;'); var textAreaElem = $('&lt;textarea rows="10" cols="75"/&gt;'); colElem.append(textAreaElem); rowElem.append(colElem); textAreaElem.val(value); var btnCol = $( '&lt;td valign="top"&gt;' + '&lt;button style="width:42px; vertical-align:middle; margin:2px;" title="delete"&gt;' + '&lt;span class="ui-icon ui-icon-trash" style="float:left;"/&gt;' + '&lt;/button&gt;' +'&lt;/td&gt;'); rowElem.append(btnCol); $("button", btnCol).click(action); } </code></pre> <p>In the button event I am using Jqury.closest to get the TR tag and label element. Below is my code for button click.</p> <pre><code>function action() { var rowElem = $(this).closest("tr"); var labelTD = $(".queryTitleCol", rowElem); } </code></pre> <p>But labelTD , I am always getting as [td.queryTitleCol] as an array. I am not able to get the td element to get the lable element. I tried with find(), but still I am getting as td array.</p> <pre><code>rowElem.find('td.queryTitleCol'); </code></pre> <p>How can I traverse and get the label name on click function of the button. Any help will be really appreciated. </p>
    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.
    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