Click here to Skip to main content
15,889,830 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Experts,

In a listview I have table contains [id, name, grade, age, notes]
notes field is displayed as a row and it's hidden by default.
I added new column called show/hide notes. in this column there's a link when the user clicks it will show or hide the notes row. so the table will look like this [id, name, grade, age,show notes, notes]
the td looks like this
HTML
<td colspan="4" style="display:none;" id="notesTd" class="showHideNotes">Notes</td>


the link looks like this :

HTML
<td style="text-align:center;vertical-align:middle;"><a href="#"><img src="img/notes1.png" class="wiringImg"  /></a></td>


Onclick of the anchor I have this JavaScript Code:
JavaScript
onclick="$('.showHideNotes').toggle();" 


The problem is If I use the class name in javaScript Code, it will show/hide all the notes of the table and If I use the Id of the td it will show/hide the first row only.
What I need to add to make the anchor show/hide the note of the row not all the rows.

I hope I well explained my problem.

Thank you
Posted
Updated 12-Jun-15 5:32am
v3

1 solution

I found the solution, I had to look for the parent of the td
So I changed javaScript to :
JavaScript
onclick="$(this).parent().parent().next().find('#notesTd').toggle();"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900