Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


convert this namespace into jQuery

Posted on 2013-12-01
Medium Priority
Last Modified: 2013-12-03
I have the following code but how would you convert it into a jQuery namespace

    multiply: function(x,y) {
        return (x * y);
//function call

Open in new window

Question by:stargateatlantis
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 36

Expert Comment

by:Miguel Oz
ID: 39688678
Use the jQuery.fn.extend method:
    multiply: function(x,y) {
        return (x * y);

Open in new window

or you can declare your new method as:
$.fn.multiply= function(){
  return (x * y);

Open in new window

Note: The first alternative is more flexible and reusable as discussed below:
LVL 44

Accepted Solution

Rainer Jeschor earned 2000 total points
ID: 39688690

could look like this:
var JQUERY4U = {}; 
;(function($) {

     JQUERY4U.EESample= {
         multiply: function(x,y) {
        return (x * y);

Open in new window

(adjusted from http://www.jquery4u.com/javascript/jquery-function-namespacing-plain-english/)

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
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…

610 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