last day (14 days later) » 

10:18 AM
1
A: Get text from previous row after clicking button in table

Zakaria AcharkiIdentifier id should be unique in same document so try to replace all the duplicate ids by general class, check example bellow. Hope this helps. $('body').on('click', '.comnowBtn', function(){ alert( $(this).closest('tr').prev('.idRow').text() ); }) <script src="https://ajax.google...

 
you're right, I edited the question to better explain the problem
 
This answer not resolving your problem?
 
I checked but unfortunately - no :( originally I had no <td> because I append things to the <tr> (var row="<tr>......"). I added the <td> but it still doesn't work
 
Why it's work in the snippet.. check my updare.
It's not a valid HTML if you're not using td and the Browser will add them automatically.
Make sure that you're using event delegation on() in click event like i have in my answer since you deal with fresh DOM added dynamically/
 
still doesn't work with <td>.....damn
 
10:18 AM
Can you create jsfiddle.net example?
 
can you open the link? - jsfiddle.net/petaqm96
 
This is your code work fine after some changes jsfiddle.net/petaqm96/1.
 
Thank you ^_^ *the fiddle is just an example of the code . btw- if I ask for $('#table').find('.idRow').text() it gives me the text of all the idRow rows... so it can read them, just have to find the right combination ....
Still can't get it to work, but I'll keep trying! Thanks for all the help!
 
Hi @AlexK what not work exactly.
 
"closest" and "prev" do not work, only "next"- see the edit I added in the question...so weird....
 
10:18 AM
Hi alex
are you there
?
 
 
1 hour later…
11:24 AM
hi
i can see that $(this).closest('tr').prev('.idRow').text() works in jsfiddle.net/petaqm96/1
from yesterday
update
 

last day (14 days later) »