Learn how to a build a cloud-first strategyRegister Now


custom jquery function

Posted on 2012-08-28
Medium Priority
Last Modified: 2012-08-29
I was wondering how do you write a custom jquery function something like this

then I can do something like this
var catId=$('#myid').categories();
Question by:stargateatlantis
1 Comment
LVL 22

Accepted Solution

Mrunal earned 2000 total points
ID: 38343989
Here is example:

(function( $ ){

  $.fn.myPlugin = function() {
    // there's no need to do $(this) because
    // "this" is already a jquery object

    // $(this) would be the same as $($('#element'));
    this.fadeIn('normal', function(){

      // the this keyword is a DOM element


})( jQuery );


Open in new window



Hope this helps you.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month20 days, 17 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question