0

我正在使用 jpicker jquery 插件供用户选择颜色,我遇到的问题是,如果您从默认颜色的第 4 列或第 5 列中选择任何颜色,则该值不会显示在我的输入框中。任何其他值都可以。

这是我如何调用代码的片段:

if($('#hexPicker').length) {
    $('#hexPicker').jPicker({
        window: {
            position: {
                y: 'center'
            }
        }   
    });
}

<input type="text" name="color" class="small" id="hexPicker"  />

我创建了一个测试帐户供你们在开发服务器上使用,以便您了解我的意思。我无法在其他任何地方重现此问题。

4

1 回答 1

1

它将输入框中的文本颜色更改为白色,因此它是不可见的。如果您选择一种颜色并使用萤火虫或开发者工具,您会看到:

<input type="text" id="hexPicker" class="small" value="02140b" name="color" style="background-color: rgb(15, 86, 51); color: rgb(255, 255, 255);">

如果您使用萤火虫编辑功能将“颜色”下末尾的值更改为 0,0,0,则该值会出现。见下文。

<input type="text" id="hexPicker" class="small" value="02140b" name="color" style="background-color: rgb(15, 86, 51); color: rgb(0, 0, 0);">

一个可能的解决方法是添加一些 jQuery,以便每当值更改时,您手动将文本的颜色重置为黑色:

$('#hexPicker').change(function() {
     $('#hexPicker').css('color','rgb(0,0,0)');
});
于 2012-02-07T15:05:28.453 回答