Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

anchor element onclick not working

//Onclick event of anchor tag won't work if href is set.
//Workaround: make href call a function that does onclick and then redirects page to link address
//NOT GOOD: <a href="/info" onclick="doSomething();" >Link </a>
//BETTER: <a href="javascript:onLinkClick();" >Link </a>
function onLinkClick()
{
  doSomething();
  window.location.href = "/info";
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: fs.writefilesync in nodejs 
Javascript :: remove border textinput react native 
Javascript :: drupal 8 get url from node entity 
Javascript :: .env file node js 
Javascript :: add access-control-allow-origin in node js 
Javascript :: javascript count instances in string 
Javascript :: jquery array 
Javascript :: javascript line through 
Javascript :: react json object pretty 
Javascript :: open a particular slide on click button in owl carousel 
Javascript :: jquery validation submit handler 
Javascript :: jquery read query string 
Javascript :: javascript find string between two characters 
Javascript :: Changing the img src using jQuery. 
Javascript :: jquery get id 
Javascript :: javascript merge two objects 
Javascript :: prop-types install npm 
Javascript :: fetch post 
Javascript :: js localstorage 
Javascript :: check if type is blob javascript 
Javascript :: print table javascript 
Javascript :: To append dropdown option using jquery 
Javascript :: ajax post variable values 
Javascript :: json javascript 
Javascript :: node js throw error 
Javascript :: replace all occurrences of a string in javascript 
Javascript :: how to edit website 
Javascript :: for htmlcollection javascript 
Javascript :: select all checkbox jquery 
Javascript :: prime number js 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =