Javascript examples for DOM HTML Element:Anchor
show alert/console log message on hyperlink click
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> function getVal(fid) {//from w w w .j a v a2s. c o m if (fid != null && fid != undefined && fid != "") console.log('hi') else console.log("else!"); } </script> </head> <body> <a href="##" onclick="getVal();">test</a> <a href="##" onclick="getVal(2134);">test</a> <a href="##" onclick="getVal('2234');">test</a> </body> </html>