//set href for all links=>stackoverflow
$('a').each(function(){
\t $(this).attr('href','https://stackoverflow.com');
});
var click_counter=0; //counter of click
$('a').click(function(){
setTimeout(function(){ //timeout for open link
\t click_counter++; //first click => 1
\t if(click_counter==1){
\t \t $('a').each(function(){
\t \t //replace all hrefs
\t \t \t var second_link=$(this).attr('second-link');
\t \t \t $(this).attr('href', second_link);
\t \t });
\t }
\t },500);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<a href="" target="_blank" second-link="https://www.yahoo.com">yahoo</a><br>
<a href="" target="_blank" second-link="https://www.wikipedia.org">wikipedia</a><br>
<a href="" target="_blank" second-link="https://www.amazon.com">amazon</a><br>
<a href="" target="_blank" second-link="https://www.gm.com">General Motors</a><br>
の下に与えられたサンプルのonclick広告コード