Why does JS Fiddle give me the error `Uncaught TypeError: undefined is not a function `?

Steven

I'm testing a Plupload script when I keep getting `Uncaught TypeError: undefined is not a function .

Not able to figure out why, I tested with an example from jQuery. I get the same error (se fiddle).

Can anyone tell me why this isn't working?

Code:

$( "div" ).greenify({
  color: "orange"
});

(function ( $ ) {
    $.fn.greenify = function( options ) {
       // Do stuff here
    };
}( jQuery ));
T.J. Crowder

Because you have those in the wrong order:

// First add the plugin
(function ( $ ) {
    $.fn.greenify = function( options ) {
       // Do stuff here
    };
}( jQuery ));

// THEN use it
$( "div" ).greenify({
  color: "orange"
});

Updated Fiddle

The general order of things is:

  1. script tag for jQuery
  2. script tags for any plugins
  3. script tag(s) for your code

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why is there an error, "Uncaught TypeError: undefined is not a function"?

Why does python give me a TypeError for this function? (new to coding)

Why does the variable give me a TypeError but the function doesn't?

Why the error? Uncaught TypeError: Cannot read property 'function' of undefined `

why does its not rendering data from API instead showing this error "Uncaught TypeError: Cannot read properties of undefined (reading 'map' " Help me

why does using cin function give me error?

"Uncaught TypeError: undefined is not a function" console error appearing

drupal jquery error: Uncaught TypeError: undefined is not a function

Error message "Uncaught TypeError: undefined is not a function" (DataTable)

BigVideo.js - Uncaught TypeError: undefined is not a function

Ember.js: Uncaught TypeError: undefined is not a function

Uncaught TypeError: undefined is not a function - typeahead.js

Why does it give an error 'searchInput' of undefined

Why does call to an undefined function does not give a compiler error and gives linker error in C?

Why does my function give me "this is not red"?

Why does the function glViewport () give me errors?

Uncaught TypeError: undefined is not a function

Uncaught TypeError: undefined is not a function

Uncaught TypeError: undefined is not a function?

Uncaught TypeError: undefined is not a function $

Why does this html code give me an error?

Why does this IQueryable issue give me an error?

Why does TypeScript give me an 'Object is possibly undefined' error when using array.at(-1)?

Why does classList return an error: Uncaught TypeError: Cannot read properties of undefined (reading 'classList')?

Why TypeScript compiler does not give error when function returns undefined while function's return type is number?

Getting a error "Uncaught TypeError: undefined is not a function" when calling a function

C, Why does my custom free function give me the "pointer being freed was not allocated" error

Why does a SELECT INTO sql statement give me an error in this Pl/SQL Function?

Why does this error 'TypeError: undefined is not an object' occur