我如何在jQuery元素上运行自定义函数? [英] How can I run a custom function on a jQuery element?
本文介绍了我如何在jQuery元素上运行自定义函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$(。my_selected .element)。myCustomFunction();
或者甚至可以简单地这样做?
$(。my_selected .element)。???????(myCustomFunction());
函数会知道 $(this)
等于 $(。my_selected .element)
。
谢谢!
$ div class =h2_lin>解决方案
$。fn.myCustomFunction = function(){
// this or $(this)是$(。my_selected .element)
}
How can I achieve this?
$(".my_selected .element").myCustomFunction();
or maybe even simply this?
$(".my_selected .element").???????(myCustomFunction());
Where the function will know that $(this)
equals $(".my_selected .element")
.
Thank you!
解决方案
$.fn.myCustomFunction = function(){
// this or $(this) is $(".my_selected .element")
}
这篇关于我如何在jQuery元素上运行自定义函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文