Given the code below, how can you get unbind('click', h)
to work?
It doesn't currently work. I could make h
a global variable but I don't know how to "set this up" given the msg
variable is set within the function.
??
function x(open) {
var msg = "blah";
var h = function (e) {
e.preventDefault();
showDialog(msg);
开发者_Go百科 };
if (open === true) {
but.unbind('click');
link.unbind('click');
} else {
but.click(h);
link.click(h);
}
}
msg = "blah"
h = function(e)
{
e.preventDefault();
showDialog(msg);
};
function x(open)
{
msg = "whatever";
if (open === true)
{
but.unbind('click', h);
link.unbind('click', h);
}
else
{
but.click(h);
link.click(h);
}
}
*I Think
精彩评论