How to get the content of first cell of a table using jquery if table is made using ThymeleafAdd table row in jQueryHow do I check if an element is hidden in jQuery?How do you get a timestamp in JavaScript?How to get the children of the $(this) selector?Get current URL with jQuery?How can I know which radio button is selected via jQuery?How to check whether a checkbox is checked in jQuery?How do I make the first letter of a string uppercase in JavaScript?Get selected text from a drop-down list (select box) using jQueryHow can I refresh a page with jQuery?

Could the museum Saturn V's be refitted for one more flight?

Obtaining database information and values in extended properties

Sums of two squares in arithmetic progressions

Could neural networks be considered metaheuristics?

What historical events would have to change in order to make 19th century "steampunk" technology possible?

GFCI outlets - can they be repaired? Are they really needed at the end of a circuit?

Machine learning testing data

Is it a bad idea to plug the other end of ESD strap to wall ground?

Is it "common practice in Fourier transform spectroscopy to multiply the measured interferogram by an apodizing function"? If so, why?

How do conventional missiles fly?

How exploitable/balanced is this homebrew spell: Spell Permanency?

What is the fastest integer factorization to break RSA?

Convert seconds to minutes

How dangerous is XSS

Avoiding the "not like other girls" trope?

OP Amp not amplifying audio signal

Do Iron Man suits sport waste management systems?

Why didn't Boeing produce its own regional jet?

How can saying a song's name be a copyright violation?

What do you call someone who asks many questions?

How seriously should I take size and weight limits of hand luggage?

Should I tell management that I intend to leave due to bad software development practices?

Did 'Cinema Songs' exist during Hiranyakshipu's time?

How to coordinate airplane tickets?



How to get the content of first cell of a table using jquery if table is made using Thymeleaf


Add table row in jQueryHow do I check if an element is hidden in jQuery?How do you get a timestamp in JavaScript?How to get the children of the $(this) selector?Get current URL with jQuery?How can I know which radio button is selected via jQuery?How to check whether a checkbox is checked in jQuery?How do I make the first letter of a string uppercase in JavaScript?Get selected text from a drop-down list (select box) using jQueryHow can I refresh a page with jQuery?













0















The table being made dynamically using Thymeleaf. Each row of the table has a img link attached to it. On the click of which I want to get the selected rows img link first , second and third cell.



Relevant Table Code



<table class="table" id="tblDocType" style="padding: 20px 10px;">
<thead class="thead-dark">
<tr>
<th scope="col"> <b> Document Type </b></th>
<th scope="col"> <b> Practice Area </b> </th>
<th scope="col"><b> Retention Policy </b></th>
<th scope="col"> <b> Effective Date<br> Required </b></th>
<th scope="col"> <b> Termination Date<br> Required </b></th>
<th scope="col"> <b> Action</b></th>
</tr>
</thead>
<tr th:each="doctype,iterStat : $dlist">
<td th:text = "$doctype?.doctypes"></td>
<td th:text = "$doctype?.practiceAreaId"></td>
<td th:text = "$doctype?.retention_policy"></td>
<td th:text = "$doctype?.effectiveDateRequired"></td>
<td th:text = "$doctype?.terminationDateRequired"></td>
<td>
<a href="#" th:name="$doctype?.practiceAreaId" th:id="$iterStat.index" onclick="deleteTrigger(this.id)" style="color: blue;">
<span class="glyphicon glyphicon-trash"></span>
</a>
</td>
</tr>
</table>


I am trying to get the cell values using jquery.



Relevant jquery code



function deleteTrigger(id)
var value=$("#tblDocType").closest("tr").find('td:eq(0)').text();
console.log("value=",value);
var doctypesjson=
"doctypes": id,
"practiceAreaId": pracaticeareaidfrombutton
;



In the console the value is coming blank.



Please help me if you know what can be done for the problem. Thank you in advance










share|improve this question






















  • Your title is quite different to your question. Can I clarify that you want to get the first cell of a row when clicked, and then subsequently the second and third cells specifically?

    – Lewis
    Mar 21 at 20:32















0















The table being made dynamically using Thymeleaf. Each row of the table has a img link attached to it. On the click of which I want to get the selected rows img link first , second and third cell.



Relevant Table Code



<table class="table" id="tblDocType" style="padding: 20px 10px;">
<thead class="thead-dark">
<tr>
<th scope="col"> <b> Document Type </b></th>
<th scope="col"> <b> Practice Area </b> </th>
<th scope="col"><b> Retention Policy </b></th>
<th scope="col"> <b> Effective Date<br> Required </b></th>
<th scope="col"> <b> Termination Date<br> Required </b></th>
<th scope="col"> <b> Action</b></th>
</tr>
</thead>
<tr th:each="doctype,iterStat : $dlist">
<td th:text = "$doctype?.doctypes"></td>
<td th:text = "$doctype?.practiceAreaId"></td>
<td th:text = "$doctype?.retention_policy"></td>
<td th:text = "$doctype?.effectiveDateRequired"></td>
<td th:text = "$doctype?.terminationDateRequired"></td>
<td>
<a href="#" th:name="$doctype?.practiceAreaId" th:id="$iterStat.index" onclick="deleteTrigger(this.id)" style="color: blue;">
<span class="glyphicon glyphicon-trash"></span>
</a>
</td>
</tr>
</table>


I am trying to get the cell values using jquery.



Relevant jquery code



function deleteTrigger(id)
var value=$("#tblDocType").closest("tr").find('td:eq(0)').text();
console.log("value=",value);
var doctypesjson=
"doctypes": id,
"practiceAreaId": pracaticeareaidfrombutton
;



In the console the value is coming blank.



Please help me if you know what can be done for the problem. Thank you in advance










share|improve this question






















  • Your title is quite different to your question. Can I clarify that you want to get the first cell of a row when clicked, and then subsequently the second and third cells specifically?

    – Lewis
    Mar 21 at 20:32













0












0








0








The table being made dynamically using Thymeleaf. Each row of the table has a img link attached to it. On the click of which I want to get the selected rows img link first , second and third cell.



Relevant Table Code



<table class="table" id="tblDocType" style="padding: 20px 10px;">
<thead class="thead-dark">
<tr>
<th scope="col"> <b> Document Type </b></th>
<th scope="col"> <b> Practice Area </b> </th>
<th scope="col"><b> Retention Policy </b></th>
<th scope="col"> <b> Effective Date<br> Required </b></th>
<th scope="col"> <b> Termination Date<br> Required </b></th>
<th scope="col"> <b> Action</b></th>
</tr>
</thead>
<tr th:each="doctype,iterStat : $dlist">
<td th:text = "$doctype?.doctypes"></td>
<td th:text = "$doctype?.practiceAreaId"></td>
<td th:text = "$doctype?.retention_policy"></td>
<td th:text = "$doctype?.effectiveDateRequired"></td>
<td th:text = "$doctype?.terminationDateRequired"></td>
<td>
<a href="#" th:name="$doctype?.practiceAreaId" th:id="$iterStat.index" onclick="deleteTrigger(this.id)" style="color: blue;">
<span class="glyphicon glyphicon-trash"></span>
</a>
</td>
</tr>
</table>


I am trying to get the cell values using jquery.



Relevant jquery code



function deleteTrigger(id)
var value=$("#tblDocType").closest("tr").find('td:eq(0)').text();
console.log("value=",value);
var doctypesjson=
"doctypes": id,
"practiceAreaId": pracaticeareaidfrombutton
;



In the console the value is coming blank.



Please help me if you know what can be done for the problem. Thank you in advance










share|improve this question














The table being made dynamically using Thymeleaf. Each row of the table has a img link attached to it. On the click of which I want to get the selected rows img link first , second and third cell.



Relevant Table Code



<table class="table" id="tblDocType" style="padding: 20px 10px;">
<thead class="thead-dark">
<tr>
<th scope="col"> <b> Document Type </b></th>
<th scope="col"> <b> Practice Area </b> </th>
<th scope="col"><b> Retention Policy </b></th>
<th scope="col"> <b> Effective Date<br> Required </b></th>
<th scope="col"> <b> Termination Date<br> Required </b></th>
<th scope="col"> <b> Action</b></th>
</tr>
</thead>
<tr th:each="doctype,iterStat : $dlist">
<td th:text = "$doctype?.doctypes"></td>
<td th:text = "$doctype?.practiceAreaId"></td>
<td th:text = "$doctype?.retention_policy"></td>
<td th:text = "$doctype?.effectiveDateRequired"></td>
<td th:text = "$doctype?.terminationDateRequired"></td>
<td>
<a href="#" th:name="$doctype?.practiceAreaId" th:id="$iterStat.index" onclick="deleteTrigger(this.id)" style="color: blue;">
<span class="glyphicon glyphicon-trash"></span>
</a>
</td>
</tr>
</table>


I am trying to get the cell values using jquery.



Relevant jquery code



function deleteTrigger(id)
var value=$("#tblDocType").closest("tr").find('td:eq(0)').text();
console.log("value=",value);
var doctypesjson=
"doctypes": id,
"practiceAreaId": pracaticeareaidfrombutton
;



In the console the value is coming blank.



Please help me if you know what can be done for the problem. Thank you in advance







javascript jquery html thymeleaf






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 21 at 20:30









dakshita gargdakshita garg

11




11












  • Your title is quite different to your question. Can I clarify that you want to get the first cell of a row when clicked, and then subsequently the second and third cells specifically?

    – Lewis
    Mar 21 at 20:32

















  • Your title is quite different to your question. Can I clarify that you want to get the first cell of a row when clicked, and then subsequently the second and third cells specifically?

    – Lewis
    Mar 21 at 20:32
















Your title is quite different to your question. Can I clarify that you want to get the first cell of a row when clicked, and then subsequently the second and third cells specifically?

– Lewis
Mar 21 at 20:32





Your title is quite different to your question. Can I clarify that you want to get the first cell of a row when clicked, and then subsequently the second and third cells specifically?

– Lewis
Mar 21 at 20:32












1 Answer
1






active

oldest

votes


















0














Presently, it appears that your code is looking for the first TR, then within that the first TD. However, this won’t do anything as your first TR only contains TH.



In calling your deleteTrigger() function, you should pass through the element that was clicked



deleteTrigger(this); // use this for your TR lookup. 


However, since you’re using jQuery already, it may make your life easier to abandon the delete function altogether and use a listener;



$(“tr”).click(function()
$(this).find(“td”).first() // this will get the first td of a clicked row
$(this).find(“td”).eq(1) // this will get second td etc...
)





share|improve this answer























  • This is not working. I am still getting blank value in the console

    – dakshita garg
    Mar 22 at 6:16











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55288796%2fhow-to-get-the-content-of-first-cell-of-a-table-using-jquery-if-table-is-made-us%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Presently, it appears that your code is looking for the first TR, then within that the first TD. However, this won’t do anything as your first TR only contains TH.



In calling your deleteTrigger() function, you should pass through the element that was clicked



deleteTrigger(this); // use this for your TR lookup. 


However, since you’re using jQuery already, it may make your life easier to abandon the delete function altogether and use a listener;



$(“tr”).click(function()
$(this).find(“td”).first() // this will get the first td of a clicked row
$(this).find(“td”).eq(1) // this will get second td etc...
)





share|improve this answer























  • This is not working. I am still getting blank value in the console

    – dakshita garg
    Mar 22 at 6:16















0














Presently, it appears that your code is looking for the first TR, then within that the first TD. However, this won’t do anything as your first TR only contains TH.



In calling your deleteTrigger() function, you should pass through the element that was clicked



deleteTrigger(this); // use this for your TR lookup. 


However, since you’re using jQuery already, it may make your life easier to abandon the delete function altogether and use a listener;



$(“tr”).click(function()
$(this).find(“td”).first() // this will get the first td of a clicked row
$(this).find(“td”).eq(1) // this will get second td etc...
)





share|improve this answer























  • This is not working. I am still getting blank value in the console

    – dakshita garg
    Mar 22 at 6:16













0












0








0







Presently, it appears that your code is looking for the first TR, then within that the first TD. However, this won’t do anything as your first TR only contains TH.



In calling your deleteTrigger() function, you should pass through the element that was clicked



deleteTrigger(this); // use this for your TR lookup. 


However, since you’re using jQuery already, it may make your life easier to abandon the delete function altogether and use a listener;



$(“tr”).click(function()
$(this).find(“td”).first() // this will get the first td of a clicked row
$(this).find(“td”).eq(1) // this will get second td etc...
)





share|improve this answer













Presently, it appears that your code is looking for the first TR, then within that the first TD. However, this won’t do anything as your first TR only contains TH.



In calling your deleteTrigger() function, you should pass through the element that was clicked



deleteTrigger(this); // use this for your TR lookup. 


However, since you’re using jQuery already, it may make your life easier to abandon the delete function altogether and use a listener;



$(“tr”).click(function()
$(this).find(“td”).first() // this will get the first td of a clicked row
$(this).find(“td”).eq(1) // this will get second td etc...
)






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 21 at 20:42









LewisLewis

1,878821




1,878821












  • This is not working. I am still getting blank value in the console

    – dakshita garg
    Mar 22 at 6:16

















  • This is not working. I am still getting blank value in the console

    – dakshita garg
    Mar 22 at 6:16
















This is not working. I am still getting blank value in the console

– dakshita garg
Mar 22 at 6:16





This is not working. I am still getting blank value in the console

– dakshita garg
Mar 22 at 6:16



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55288796%2fhow-to-get-the-content-of-first-cell-of-a-table-using-jquery-if-table-is-made-us%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript