0

我是 javascript/jquery 的新手,我在网上做了一些探索,但我不知道为什么以下内容无效:

var toggleSection = function(sectionName) {
// Do some Jquery work to toggle stuff based on sectionName string
// (concatenate sectionName with other text to form selectors)
};
$('#togglecont1').click(toggleSection("container1"));

我有什么明显的遗漏吗?提前致谢。

4

1 回答 1

0

您尝试在单击处理程序定义中调用该函数,但这是行不通的。你可以这样做:

$('#togglecont1').click(function(){
    toggleSection("container1");
});
于 2010-03-27T23:19:36.663 回答