-4
Dans ma page html Je veux obtenir noeud html sur son clic href.Get noeud html sur clic href
exemple:
FICHIER HTML
<!DOCTYPE html>
<html>
<body>
<p><a href="https://www.w3schools.com/html/" data-type="W3">Click1</a></p>
<p><a href="https://www.google.com/html/" data-type="google">Click2</a></p>
</body>
</html>
Lorsque Click1
est cliquée Je veux valeur: W3
Lorsque Click2
est cliquée Je veux valeur: google
Actuellement, je suis en utilisant document.documentElement.outerHTML
pour obtenir la chaîne html complète et l'analyser. Y at-il un meilleur moyen d'obtenir la valeur data-type
sur un clic href?