Created
April 17, 2017 15:53
-
-
Save Hexodus/a68cef168d32635c53ab2f06f7492aac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.fn.messagePlugin = function(){ | |
var selectedObjects = this; | |
return { | |
saySomething : function(message){ | |
$(selectedObjects).each(function(){ | |
$(this).html(message); | |
}); | |
return selectedObjects; // Preserve the jQuery chainability | |
}, | |
anotherAction : function(){ | |
//... | |
return selectedObjects; | |
} | |
}; | |
} | |
// Usage: | |
$('p').messagePlugin().saySomething('I am a Paragraph').css('color', 'red'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment