【发布时间】:2011-03-31 17:20:40
【问题描述】:
我不是最擅长这个 jquery 的东西。但我试图将操作与函数分开,以便我可以应用多个导致相同函数的事件。不幸的是,这不起作用。有人知道为什么吗?
更新了函数,但还是报错
$(document).ready(function() {
var $info_items = jQuery('.checkbox.has_info, .has_info');
$info_items.click(function(event) {
$(this).show_text(event);
});
// I suspect it has something to do with this initalizer of the function here
jQuery.fn.show_text = function(event){
var $info_item = jQuery(this);
$info_items.filter(function(index){
return $(".hidden_text").css("display","block");
}).not($info_item).parent().next().next().hide("slow");
$info_item.parent().next().next().show("fast");
});
});
【问题讨论】:
-
下次请使用更好的主题行。可能类似于“如何将多个事件应用于同一个函数”。
标签: javascript jquery oop function