Andrew Allen West
Andrew Allen West

Reputation: 734

jquery css change outline of input to none

Ok. I know some of you are reading this and already asking why I'm so stupid and why I dont do this with simple CSS.

input:focus { outline:none; }

Simple... for some reason wordpress is not allowing this change to happen - so I am reverting to jquery to do the dirty work.

Problem is for me.. I can't get it to work either....

http://jsfiddle.net/h5KEm/ is the link to the following code on jsfiddle:

<form action="" method="post">
<input id="optin" name="optin"><br />
<input type="submit" id="submit" name="submit" value="go">
</form>​

$('input[name=optin]').click(function() {
    $(this).css('outline', none');    
});​

Upvotes: 2

Views: 4323

Answers (2)

Derek
Derek

Reputation: 132

You can also change from the click event to the focus event

$('input[name=optin]').focus(function() {
    $(this).css('outline', 'none');    
});

Upvotes: 0

Denys S&#233;guret
Denys S&#233;guret

Reputation: 382234

Just a typo (a missing quote) :

$('#optin').click(function() {
    $(this).css('outline', 'none');    
});​

Note that I also replaced 'input[name=optin]' by '#optin' because this is cleaner and faster to use the id when you have one.

Upvotes: 8

Related Questions