 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to write a custom jQuery plugin?
To create a jQuery plugin, first create a file named jquery-demoplugin.js with the following code. This is our plugin code. Here, demoplugin is the name of our plugin. You can add any name to your custom plugin −
(function ( $ ) {    $.fn.demoplugin = function( options ) {       var web = $.extend({          name: 'example'       }, options );       return this.append('Website: ' + web.name + '.com');    }; }( jQuery )); Now, to load it, add to the HTML file, new.html −
<html> <head> <script src=" https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="jquery-demoplugin.js"></script> <script> $( document ).ready(function() { $( '#content ).demoplugin(); }); </script> </head> <body> <div id="content"></div> </body> </html>
Advertisements
 