- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › How can I get CSS proerties of element with jquery ?
Hey,
I want Get CSS properties of element for example
<p>
from style.css
and then I want set it for another element for example <a></p>
I generally try to avoid manipulating the CSS directly with jQuery.
Instead of doing something like this:
$('.element').css({
border : '1px solid red',
background : 'blue
// etc
});
I’d rather to do this:
$('.element').addClass('something');
And then in your CSS file:
.something {
border: 1px solid red;
background: blue;
/* etc */
}
So instead of getting the CSS properties via jQuery, you should probably be figuring out how to utilize classes.
Thx TheDoc for your efforts ,
I will tell you what i want to do
I want to replace <header>
with <div id="header">
for old browsers and this is ok using replaceWith() jQuery method , then i want get css properties of tagname <header>
and set it for new ID #header
.
That seems like a lot of work when you could just use the HTML5Shiv and you wouldn’t need to replace the header at all.
Even if you did, you don’t need to copy the properties over…
header,
#header {
your properties here;
}
A grand total of 8 characters extra.
thx Paulie_D ,
but i will force every one use my code do this and i don’t want this
as I want to Create something like HTML5Shiv