Problem statement :In my code I have onclick and href on one element and I want to call href first. I searched every where but I found opposite solution i.e first click event trigger then href calls.
See this example: http://jsfiddle.net/kevalbhatt18/y5qmLmxk/2/
var tmp1 ="www.mysite.com"
document.body.innerHTML+='<div style="margin-left:10;"><li class="highlight"><a href="'+tmp1+'" onclick="highlightSearch(this);">test Span</a></li></div>';
function highlightSearch(scope){
event.preventDefault();
var href = scope.href
window.location = href;
console.log('ddd');
}
I tried without preventDefault same thing happens, so i thought i can call href in click event like above example. but it gives me same result.
So it is possible to call href first, then other part of click.
Edit :
see in console when you run fiddle.
you can see console print first then href called. so my quetion is different