クリックイベントを処理する名前付き関数内のCSSプロパティを変更したい。私が.cssをclickイベントで定義された無名関数で呼び出すと、それは機能します。しかし、私は.cssをハンドラ関数の中で定義された名前付き関数の中で呼びたいと思っています。ここに私のコードです。.css関数がハンドラ関数の内部で機能しない
$(document).ready(function() {
$('#popup').click(partial(coolTransition, $(this)));
});
function coolTransition(elem) {
shrink();
function shrink() {
elem.css('background-color', '#000000');
}
}
//used to implement partial function application so that I can pass a handler reference that takes arguments.
//see http://stackoverflow.com/questions/321113/how-can-i-pre-set-arguments-in-javascript-function-call-partial-function-applic
function partial(func /*, 0..n args */) {
var args = Array.prototype.slice.call(arguments, 1);
return function() {
var allArguments = args.concat(Array.prototype.slice.call(arguments));
return func.apply(this, allArguments);
};
}
ご協力いただきありがとうございます。
「this」は2行目で何を指していると思いますか? –