How to parse the default css property to inline style attribute

Tags: jquery,html,css,html5

Problem :

At the moment I have a page where users can create divs and drag/drop them into another div id="holder".

I have a save button that gets the html of holder. $('#Holder').html();

The divs in holder have some styling from a CSS file and inline styling: style="left:10px; right:10px; background-color:#000000;" added by jQuery.

What I want is to combine the styling from my CSS file with the inline styling so I am able to use $('#holder').html(); and have all styles.

Question: How can I parse the CSS styling into the style="" attr.

So after the info an example of what I have:

As you can see im missing the width, height and position style.

== EDIT ==

After looking at given link I'm still stuggling with this.

I still can't combine the inline style and CSS style from file.


Solution :

That's not as easy as it sounds, not by a long shot. If you want to look at an object's CSS properties, you can use the .css() function jQuery provides. Essentially, you'd retrieve each of the element's styles via the .css() function and reapply them to the element with the method. Then, theoretically, .html() would give you a list of all the CSS styles on that element.

Are you sure that's what you need, or can you just use .css() the way it's intended?

    CSS Howto..

    how to make target link work giving different css properities

    How to cut down HTTP request on js/css in laravel

    How to make a 3D banner overlay (??) with CSS

    how to to set chat box based on user id using css

    Bootstrap progress bar with gradient color showing proportionally on active width

    Codeigniter: how to access css files from different views?

    How to make a css media query snippet in ATOM editor

    how to spread small image file in background and it should scroll with other elements

    how to scale an image disproportionally via css?

    How do I draw a line in CSS that starts wide and ends in a point [duplicate]

    How to create an div background that is not affected by page zoom with CSS

    How do I get content to overflow into another div if there is room, using css?

    How to create overlaying papers (pile) - CSS / HTML

    How can I use Perl to get a list of CSS elements with a color or background color attribute?

    Mojolicious Tests: How to get the input value using css-selectors

    using the unorthodox `head {display: block}` to show text to user?

    How do I create triangle shaped vertical breadcrumbs

    How to Over ride youtube external style?

    How to stretch images with no antialiasing

    PrimeFaces: how to override CSS class

    How to add a class to an element with CSS

    How to align more than one DIVs which list of letters to the center

    How to perform --include-css when using the Jekyll stylus plugin

    How do I get IE to display CSS DIV tables properly?

    How to prevent PHP pushed HTML tables exceeding the length of the page

    How to implement fade in effect for CSS checkbox

    How to move object into the screen from outside via jQuery transition

    How to make lightbox scroll the lightbox and not the page

    how to fit the background image to the containing anchor element?

    How to make my .css and .js file work with my html code loaded in a WebView on Android