How do you create a jQuery plugin?
<p class="a">One</p><p class="a">Two</p>
$.fn.markAs = function (options) {
var settings = $.extend({ label: 'done' }, options);
return this.each(function () {
$(this).addClass(settings.label);
});
};
$('.a').markAs({ label: 'checked' });
HTML after the code runs
<p class="a checked">One</p>
<p class="a checked">Two</p>
See jQuery Plugins.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |