我不是最好的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");
});
});
下次請使用更好的主題行。也許就像「如何將多個事件應用於同一個功能」。 – Bart 2010-08-18 18:18:30