I am a beginner with javascript. I have an html table with contenteditable data, I would like to use javascript to add numbering next to each line inside the "contenteditable" column after entering TAB:
<table> <tr> <td contenteditable="true" >First column</td> </tr> </table>
Any help would be appreciated. Thanks!
If by "line number", you mean "column number", this will work:
<table> <tr> <td contenteditable="true" >First column</td> <td contenteditable="true" >Second column</td> </tr> </table> <script> let index = 1 document.querySelectorAll('td').forEach((td) => { td.innerText += " " + index index += 1 }) </script>
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.