javascript - jQuery: Simple plugin does not work -
i trying create plugin jquery. basic plugin (plugin.js)
(function ( $ ) { $.fn.testplugin= function() { alert('test'); }( jquery )); this file (ext.js) calls function testplugin() inside plugin.js
$(document).ready(function(){ $('p').testplugin(); }; in html page included files above plus jquery library (jquery.js)
<script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/plugin.js"></script> <script type="text/javascript" src="js/ext.js"></script> unfortunately plugin not work expected.
well, simple example work (after removed ) mentioned tibzon , wojtek).
$.fn.testplugin=function(){ alert('test'); }; $('p').testplugin() <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> i left out enclosing parenthetical expression (function($){ ... })(jquery) doesn't make difference example chosen. variable affected $ itself.
Comments
Post a Comment