How to create simple jQuery plugin?(如何创建简单的 jQuery 插件?)
问题描述
这个测试插件应该是这样工作的:当一个元素被点击时,它会向下移动.就那么简单.
This test plugin, is supposed to work like this: When an element is clicked, it moves down. Simple as that.
问题是,当一个元素被点击时,它不仅会移动被点击的元素,还会移动应用插件的所有其他元素.
The problem is, when an element is clicked, it not only moves the clicked element but also ALL the other elements which the plugin was applied to.
解决办法是什么?
推荐答案
对于插件创作尝试这种方式,更可靠:
For plugin authoring try this way, much more solid:
这是 jsFiddle 示例.
插件:
用户文件:
这篇关于如何创建简单的 jQuery 插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!