Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JQuery函数在Firefox中不起作用_Jquery - Fatal编程技术网

JQuery函数在Firefox中不起作用

JQuery函数在Firefox中不起作用,jquery,Jquery,我正在使用此函数更改输入文本的颜色。当选择更改时,该函数将选择所选选项的颜色,并将其置于输入文本上。该功能在Chrome和Opera上运行良好,但在Firefox上仅更改白色的颜色。帮忙 选择: 尝试将所有代码放入DOM ready中: $(document).ready(function(){ $("#cor").change(function() { var teste = $('#cor').find('option:selected').css("color");

我正在使用此函数更改输入文本的颜色。当选择更改时,该函数将选择所选选项的颜色,并将其置于输入文本上。该功能在Chrome和Opera上运行良好,但在Firefox上仅更改白色的颜色。帮忙

选择:


尝试将所有代码放入DOM ready中:

$(document).ready(function(){
    $("#cor").change(function() {
        var teste = $('#cor').find('option:selected').css("color");
        $( '#usuario' ).css("color",teste);
    }).change(); // here you can trigger .change() instead of separate handler
});
为了从HTML中获取颜色值作为名称,您可以使用:

$(document).ready(function(){
    $("#cor").change(function() {
        var teste = $('#cor').find('option:selected')[0].style.color;
        console.log(teste);
        $( '#usuario' ).css("color",teste);
    }).change(); // here you can trigger .change() instead of separate handler
});

我将所有代码都放在DOM ready中,但在firefox中不起作用。。。我在Firefox上发布了一个警报,以查看捕获到的颜色,它只返回RGB255255255。有没有其他方法来捕捉颜色?你期望的结果是什么?在Firefox上对我来说效果很好:我的预期结果是所选选项的颜色,第一个选项是黑色,第二个是蓝色,最后一个是红色。我需要返回以输入文本的颜色。在Chrome和Opera上运行良好,但在Firefox上不起作用。如果你愿意,可以在那个链接上看到:谢谢,伙计,现在已经在Firefox上工作了!对不起,我没有经验,英语很差。真的谢谢!
$(document).ready(function(){
    $("#cor").change(function() {
        var teste = $('#cor').find('option:selected').css("color");
        $( '#usuario' ).css("color",teste);
    }).change(); // here you can trigger .change() instead of separate handler
});
$(document).ready(function(){
    $("#cor").change(function() {
        var teste = $('#cor').find('option:selected')[0].style.color;
        console.log(teste);
        $( '#usuario' ).css("color",teste);
    }).change(); // here you can trigger .change() instead of separate handler
});