7. Let's .focus()!


#1


https://www.codecademy.com/courses/web-beginner-en-JwhI1/1/3?curriculum_id=50a3fad8c7a770b5fd0007a1#


Codecademy says I have passed, however when I focus the outline still changes to blue rather than red.


$(document).ready(function(){
    $('input').focus(function(){
        $(this).css('outline-color','#FF0000');
    });
});


#2

That's because #FF0000 is red, not blue.

Source: color-hex.com


#3

That's what I mean. I've asked it to change to red (i.e. #FF0000), but it's still changing to blue for some reason that I can't figure out. :slight_smile:


#4

Could you provide a screenshot please?


#5

I've hovered my pointer over the bar in the screenshot below:


#6

Does your CSS establish a set border color? If not it might just be a glitch.


#7

I think it's just a glitch. Thanks for your help : )


#8

Getting the same here. My script.js is:
$(document).ready(function(){
$("input").focus(function(){
$(this).css("outline-color","#FF0000");
});
});
But no red on the outline-color. I believe it turning blue is default browser behavior. I tried other things like adding a div to HTML and changing it's background-color and that didn't work either...


#9

It might be a browser thing. I'm not too familiar with IE or Edge or whatever it's called now.

You can try using CSS and giving the input box a pseudo-selector or pseudo-event (I can't quite recall what their official name is) to make it turn red on hover or click.


#10

perfectly working and changing colour to red


#11

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.