How to parse the default css property to inline style attribute

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: http://jsfiddle.net/Ub9ZD/

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.

Progress: http://jsfiddle.net/Ub9ZD/39/

Answers


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 htmlELement.style 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?


Need Your Help

Handling BSTRs on MacOSX in C

c osx vba bstr

I've written some code in C for converting strings passed from VBA, when the C code is called from VBA from a MacOSX dylib. I got some good hints here, and since I only care about ASCII strings I've

C++ template class confusion

c++ templates

So i am a fairly experienced C programmer who recently took a dive into C++ for a toy-compiler I am writing. I am currently "modernizing" my C++ code because my current code looks more like ANSI-C ...