527
votes
16answers
589k views

Change an element's CSS class with JavaScript

How can I change a CSS class of an HTML element in response to an onClick event using JavaScript?
407
votes
11answers
18k views

Is the recommendation to include CSS before JavaScript invalid?

In countless places online I have seen the recommendation to include CSS prior to JavaScript. The reasoning is generally, of this form: When it comes to ordering your CSS and JavaScript, you want ...
273
votes
24answers
71k views

What is an elegant way to force browsers to reload cached CSS/JS files?

I have noticed that some browsers (in particular, Firefox and Opera) are very zealous in using cached copies of .css and .js files, even between browser sessions. This leads to a problem when you ...
161
votes
6answers
57k views

How to disable resizable property of TextArea?

I want to disable the resizable property of a TextArea. Currently, I can resize a TextArea by clicking on the bottom right corner of the TextArea and dragging the mouse. Is it possible to disable ...
147
votes
11answers
34k views

How to remove the space between inline-block elements?

Given this HTML: <p> <span> Foo </span> <span> Bar </span> </p> and this CSS: span { display:inline-block; width:100px; } as a result, there ...
145
votes
5answers
14k views

Convert RGB-->RGBA

I have a hex color, e.g. #F4F8FB (or rgb(244, 248, 251)) that I want converted into an as-transparent-as-possible rgba color (when displayed over white). Make sense? I'm looking for an algorithm, or ...
129
votes
13answers
5k views

Isn't it silly that a tiny favicon requires yet another HTTP request? How to make favicon go into a sprite?

Everybody knows how to setup a favicon.ico link in HTML: <link rel="shortcut icon" href="http://hi.org/icon.ico" type="image/x-icon" /> But I think it is just silly that for a tiny ...
125
votes
3answers
88k views

Determine if an element has a CSS class with jQuery

I'm working with jQuery and looking to see if there is an easy way to determine if the element has a specific CSS class associated with it. I have the id of the element, and the CSS class that I'm ...
124
votes
11answers
135k views

Dynamically retrieve the position (X,Y) of an HTML element

I want to know how to get the X and Y position of HTML elements such as img and div in JavaScript.
116
votes
7answers
86k views

jQuery - remove style added with .css() function

I'm changing CSS with jQuery and I wish to remove the styling I'm adding based on the input value: if(color != '000000') $("body").css("background-color", color); else // remove style ? How can I ...
113
votes
3answers
44k views

Can jQuery get all CSS styles associated with an element?

Is there a way in jQuery to get all CSS from an existing element and apply it to another without listing them all? I know it would work if they were a style attribute with attr(), but all of my ...
98
votes
7answers
26k views

Can I hide the HTML5 number input’s spin box?

Is there a consistent way across browsers to hide the new spin boxes that some browsers (such as Chrome) render for HTML input of type number? I am looking for a CSS or JavaScript method to prevent ...
90
votes
10answers
72k views

HTML table with fixed headers?

Is there a cross-browser CSS/JavaScript technique to display a long HTML table such that the column headers stay fixed on-screen and do not scroll with the table body. Think of the "freeze panes" ...
86
votes
11answers
23k views

Google's Imageless Buttons

There have been a few articles recently about Google's new imageless buttons: http://stopdesign.com/archive/2009/02/04/recreating-the-button.html http://stopdesign.com/eg/buttons/3.0/code.html ...
86
votes
9answers
71k views

Best jQuery rounded corners script? [closed]

I've been looking at various scripts for adding automatic rounded corners to a div using jQuery but there are loads of plugins available, none of which seem perfect. So, does anybody know of a script ...

1 2 3 4 5 1705
15 30 50 per page