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?
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
add a comment |
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
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
add a comment |
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
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
javascript jquery html thymeleaf
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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...
)
This is not working. I am still getting blank value in the console
– dakshita garg
Mar 22 at 6:16
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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...
)
This is not working. I am still getting blank value in the console
– dakshita garg
Mar 22 at 6:16
add a comment |
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...
)
This is not working. I am still getting blank value in the console
– dakshita garg
Mar 22 at 6:16
add a comment |
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...
)
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...
)
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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