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
Post a Comment