开发者

Registering a Named Function as a Listener with Jquery

开发者 https://www.devze.com 2022-12-25 01:39 出处:网络
I\'m new to javascript/jquery and I\'ve done some poking around the web, 开发者_JAVA技巧but I can\'t figure out why the following is invalid:

I'm new to javascript/jquery and I've done some poking around the web, 开发者_JAVA技巧but I can't figure out why the following is invalid:

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"));

Is there something obvious I'm missing? Thanks in advance.


Your trying to call the function inside the click handler definition, which won't work. you could do something like this:

$('#togglecont1').click(function(){
    toggleSection("container1");
});
0

精彩评论

暂无评论...
验证码 换一张
取 消