gpt4 book ai didi

JavaScript + jQuery 这个范围

转载 作者:行者123 更新时间:2023-11-28 09:24:48 25 4
gpt4 key购买 nike

我遇到了这个问题 - 我真的无法自己解决。我已经下载了this jQuery plugin

我有 x 个 jQuery 对象的 div 正在通过以下方式扩展:

    $('.colorSelector').ColorPicker({
color: '#0000ff',
onShow: function (colpkr) {
$(colpkr).fadeIn(500);
return false;
},
onHide: function (colpkr) {
$(colpkr).fadeOut(500);
return false;
},
onChange: function (hsb, hex, rgb) {
$('.colorSelector div').css('backgroundColor', '#' + hex);
}
});

我想要的是检索 $('.colorSelector') 'this' 引用(在 ColorPicker 方法的对象内)并替换 'css' 方法可以分配给的 onChange 方法$(this) 选择器而不是 $(.colorSelector div')

最佳答案

我不确定你的问题,但我认为你想使用 $(this) 获取子元素 div:

$(this).find('div').css('backgroundColor', '#' + hex);

如果不是这样,请澄清您的问题。

关于JavaScript + jQuery 这个范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14547234/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com