Skip to main content
Presuming more than one solution is referred to. References to relative positions of answers are not reliable as they depend on the view (votes/oldest/active) and changing of the accepted answer and change over time (for votes, active, and accepted state).
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

This way is similar to the above solutionprevious solutions, but implemented differently:

.social_icon -> some class with CSS

 <div class="social_icon" id="SOME_ID" data-url="SOME_URL"></div>   $('.social_icon').click(function(){   var url = $(this).attr('data-url'); var win = window.open(url, '_blank'); ///similar to above solution win.focus(); }); 

This way is similar to the above solution but implemented differently

.social_icon -> some class with CSS

 <div class="social_icon" id="SOME_ID" data-url="SOME_URL"></div>   $('.social_icon').click(function(){   var url = $(this).attr('data-url'); var win = window.open(url, '_blank'); ///similar to above solution win.focus(); }); 

This way is similar to the previous solutions, but implemented differently:

.social_icon -> some class with CSS

 <div class="social_icon" id="SOME_ID" data-url="SOME_URL"></div> $('.social_icon').click(function(){ var url = $(this).attr('data-url'); var win = window.open(url, '_blank'); ///similar to above solution win.focus(); }); 
Source Link
CG_DEV
  • 818
  • 8
  • 7

This way is similar to the above solution but implemented differently

.social_icon -> some class with CSS

 <div class="social_icon" id="SOME_ID" data-url="SOME_URL"></div> $('.social_icon').click(function(){ var url = $(this).attr('data-url'); var win = window.open(url, '_blank'); ///similar to above solution win.focus(); });