Referring to "this" without using .each()
I have an element $myElement that I want to refer to using this inside .css() call. Specifically, I tried to change the CSS property someCssProperty to $myElement.myProperty naively:
$myElement.css(someC开发者_如何学GossProperty, this.myProperty);
Is there a way of having a working this without using the cumbersome .each()?
css takes a function as a parameter which you can use:
$myElement.css(someCssProperty, function(index, value) {
return this.myProperty;
});
The callback also receives the index in the set and the old value as parameters.
加载中,请稍侯......
精彩评论