Proper way to have an anchor tag with onclick event
Anchor tags are one of the most common HTML tags used in pages. If the user right clicks on the anchor tag he/she will be provided with an option of 'Open in new Window/Open in new Tab'. This will happen only if the anchor has href attribute.
Sometimes it is required to do some other action (like making ajax request) on click of the anchor link and also provide the right click option for the same anchor.
Natural practice by web developers.
<a href="javascript:void(0);" onclick="alert('i am here');">Click Me! </a>
Click Me without link for anchor!
Correct way to add anchor tags without losing anchor properties.
<a href="http://www.blogger.com/amareswar.blogspot.com" onclick="alert('i am here'); return false;">Click Me! </a>
Click Me!
In the above link, you can observe that the user can right click on go to the respective link and onclick will do the custom action provided by the developer.
Sometimes it is required to do some other action (like making ajax request) on click of the anchor link and also provide the right click option for the same anchor.
Natural practice by web developers.
<a href="javascript:void(0);" onclick="alert('i am here');">Click Me! </a>
Click Me without link for anchor!
Correct way to add anchor tags without losing anchor properties.
<a href="http://www.blogger.com/amareswar.blogspot.com" onclick="alert('i am here'); return false;">Click Me! </a>
Click Me!
In the above link, you can observe that the user can right click on go to the respective link and onclick will do the custom action provided by the developer.
Comments
Appreciate your help.
-jana
Javascript Training in Chennai | HTML5 Online Training
JavaScript Training Courses | Javascript Online Training | Angular 2 Training in Chennai
JavaScript Training in CHennai HTML5 Training in Chennai HTML5 Training in Chennai JQuery Training in Chennai JQuery Training in Chennai JavaScript Training in Chennai JavaScript Training in Chennai
JavaScript Training in CHennai JavaScript Training in CHennai JQuery Online Training JQuery Online Training
HTML5 CSS3 JavaScript Training in Chennai | HTML5 Online Training
Devops Training courses
Devops Training in Bangalore
Best Devops Training in pune
Microsoft azure training in Bangalore
Power bi training in Chennai
Thank you to the perform as well as discuss anything incredibly important in my opinion. We loose time waiting for your next article writing in addition to I beg one to get back to pay a visit to our website in
selenium training in Bangalore
selenium training in Marathahalli
selenium training in Btm layout
selenium training in Jaya nagar
selenium training in Electronic city
selenium training in Kalyan nagar
python Course in Pune
python Course institute in Chennai
python Training institute in Bangalore
Full Stack Development Training in Chennai Searching for Full Stack Development training in chennai ? Bita Academy is the No 1 Training Institute in Chennai. Call for more details.
best mobile application company in indore
DevOps Training | Certification in Chennai | DevOps Training | Certification in anna nagar | DevOps Training | Certification in omr | DevOps Training | Certification in porur | DevOps Training | Certification in tambaram | DevOps Training | Certification in velachery
best digital marketing course in chennai
best digital marketing training in chennai
RPA Training in Chennai
RPA Training Online
RPA Training In Bangalore
Android Training in Anna Nagar
Android Training in Chennai
Mobile app development courses
smm panel
faturalı hatta kredi
faturalı hatta kredi
instagram takipçi satın al
binance komisyon indirimi
binance indirim kodu
instagram takipçi satın al
tiktok jeton hilesi
DevOps course in Tambaram
DevOps Training in Chennai
rest api testing training in chennai
api testing training
Top 10 Ethical Hacking Institute In Chennai