How to open a notification field in an <a href> anchor tag?

I want to open a warning window when I click on a specific link. How to do it?

+5
source share
4 answers

You can also use the following codes:

<a href="#" id="link">Link</a> 

JavaScript:

 $(document).on("click","#link",function(){ alert("I am a pop up ! "); }); 

OR

 <a href="#" onclick="alert('I am a popup!');">Link</a> 
+4
source

Without using a JS file (only as an alternative to already posted answers):

 <a href="http://example.com" onclick="alert('Hello world!')">Link Text</a> 
+1
source
 <a href="#" onclick="myFunction(); return false;"> 

return false; will stop loading the webpage after clicking.

JavaScript Code:

 function myFunction() { alert("I am a pop up ! "); } 
0
source

The following code may help: -

 <a id="anchor">i am the anchor</a> <div id="popup">this is a popup</div> <script> $(function(){ $('#popup').hide(); $('#anchor').click(function(){ $('#popup').show(); }) }); </script> 
0
source

All Articles