Hi,
Take the following example plugin:
(function($) {
$.fn.alertOnClick = function(text) {
return this.each(function(){
$(this).click(alert(text));
});
}
})(jQuery);
that I might use like this:
$('p').alertOnClick("this is a silly plugin");
How do I modify the plugin code to support doing the following:
$('p').alertOnClick("this is a silly plugin");
$('p#someSpecificP').setAlertText("different alert text");
this would have the effect that all p
's when clicked should display "this is a silly plugin"
except the p
with id "someSpecificP"
which would display "different alert text"
.
This example is obviously not my real code, but serves as an analogy. I have a plugin applied to many elements with defaults. During the life of the page, I may want to change some of the default settings for individual elements with the plugin applied to them, but not all.
Thanks