Thursday, December 10

Set attribute link "_blank" inside your body post using jquery.



Author : Henri Wijaya

If you have a lot of links inside your body post and maybe you want all of your links to be opened in new window.

You need to include JQUERY inside head tag.Just copy paste this code after your head:


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript">




Now insert this code below the script you just pasted :


<script type='text/javascript'>

$(document).ready(function(){

   $('.post-body').find('a').attr('target','_blank');

});

</script>




Now everytime when your users are clicking one of your links inside your post body then it will open new tab.You dont have to do manually by setting link target to blank.

No comments:

Post a Comment