Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing or altering CSS pseudo class in jQuery

A simple enough question, so briefly - is it possible to remove or alter in anyway a CSS pseudo class using jQuery? Or any other Javascript method for that matter

Specifically I want to get rid of :focus on inputs. I can't alter the CSS file directly in any way.

thanks for any help

Buster

like image 321
BusterLuke Avatar asked Jun 24 '11 10:06

BusterLuke


2 Answers

I can't alter the CSS file directly in any way.

Assuming you can only use JavaScript to do this, I can't think of anything better than:

$('head').append('<style>input:focus{background:#fff}</style>');

You will have to individually reset each property. font-weight:normal, color:#000 - whatever you need.

See: http://jsfiddle.net/jqpAu/

like image 187
thirtydot Avatar answered Sep 28 '22 14:09

thirtydot


Without more specific detail it's hard to answer accurately, but if you want you can just override the :focus style:

// in the CSS file
input:focus {background-color: red;} 

// in your page
input:focus {background-color: inherit;} // overrides with the parent background

Demo

like image 30
Town Avatar answered Sep 28 '22 16:09

Town