Code: Select all
(function($){
$.fn.targetblank = function(){
// alert('Working');
var targetArray = ['_blank' , '_self' , '_parent' , '_top'];
var target = jQuery.trim($(this).attr('target'));
if (target == undefined || target == '' || jQuery.inArray(target , targetArray) == false) {
$(this).attr('target' , '_blank');
} // end of if statement .
} // end of function
})(jQuery);
it gets called like this :
<body>
<a href="http://www.sitepoint.com/how-to-develop-a-jquery-plugin/" >Sitepoint Article</a>
<script src="js/jquery.js"></script>
<script src="js/pluggin.js"></script>
<script>
$(document).ready(function(){
[color=#FF0000] $('a').targetblank()[/color]
});
</script>
</body>
my questions are :
what does this line mean :
Code: Select all
(function($){
also ,
3. $.fn.targetblank = function(){
what does the above line really do ? or mean ??
Thanks .
Gautam .