javascript - How to return an object from a selector? -


i have code

$( document ).ready(function() {     $('#boxone') = new category();     $('#boxone').playfunction();     foo(); })  function category(el) {     this.playfunction() {         alert('bar')     } }  function foo() {     $('#boxone').playfunction() } 

this first playfunction() works fine, foo() returns undefined.

as understand category() class create game within element id = boxone .if true, create plugin .(http://learn.jquery.com/plugins/basic-plugin-creation/).

doing code can changed -

$('#boxone').category(); 

and functions playfunction() event based function-

$('#boxone').trigger('play'); 

in plugin , listener attached on 'play' event handler playfunction();


Comments

Popular posts from this blog

Python Kivy ListView: How to delete selected ListItemButton? -

asp.net mvc 4 - A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name '' -