i have an HTML list with some link:
<ul>
<li><a href="#" name="link1">link1</a></li>
<li><a href="#" name="link2">link2</a></li>
<li><a href="#" name="link3">link3</a></li>
</ul>
Each link has a different name.
In nodeJS, when i click the link i want to print on the console the name of the link that I clicked.
how can i do?
You can use this javascript code to print the name of the link
<ul> <li><a href="#" id="link1" name="link1" onclick ="console.log('link1')">link1</li> <li><a href="#" name="link2" onclick ="console.log('link2')">link2</li> <li><a href="#" name="link3" onclick ="console.log('link3')">link3</li> </ul>
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.