-2
rated 0 times
[
2]
[
4]
/ answers: 1 / hits: 26985
/ 9 Years ago, thu, december 31, 2015, 12:00:00
I am trying to do below code for redirect from one page to other page with that particular 'a' tag click and appended with that particular link which is in clk variable
function abc()
{
var a = document.getElementsByTagName(a);
//alert(a);
for (var i = 0; i < a.length; i++) {
a[i].onclick = function (e) {
e.preventDefault();
var clk=$(this).attr('href');
window.location='http://www.shopeeon.com?ver='+clk;
//doSomething();
}
}
}
<a id=first onclick='abc();' href=http://www.google.com >Google</a><br/>
<a id=second onclick='abc();' href=http://www.yahoo.com >Yahoo</a><br/>
<a id=third onclick='abc();' href=http://www.rediff.com >Rediff</a><br/>
<a id=third onclick='abc();' href=http://www.gmail.com >Gmail</a><br/>
<a id=third onclick='abc();' href=http://www.facebook.com >Facebook</a><br/>
The above code is not work properly that i want
e.g. suppose when i click on first link(or may be some other) then on that particular click i get href of that link and store in clk variable and also redirect to other page with that particular link.
More From » jquery