简体   繁体   中英

How to get second td value from a table using javascript

Tried to get table's tr second td value but not working.I think closest is not working in chrome or firefox properly. I am using this script in angular 6.How to resolve this issue?

const target = e.originalEvent.toElement.closest('td');

When reading the title of your question and looking at the option "Get ID" from your drop-down, I assume that you simply want to know how to write the ID of the current table row to component.selectedVal .

Since you're building individual table rows by iterating over the component.data array, the solution is straight forward. Just add below event handler to your p-dropdown element and get rid of the method component.onSelectType .

(onChange)="selectedVal= data"

Please have look at this StackBlitz

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM