How to correctly affect multiple css properties in jquery

Tags: jquery,css,html

Problem :

Below is an example of how I currently would affect two css properties for the same div in jquery:


I don't believe this to be the most efficient method as it requires two lines of code for one div, can somebody please show me a more susinct (tidier) method of writing the same thing?

Solution :

.css( properties )

properties Type: PlainObject An object of property-value pairs to set.

    "width": myvar + "px",
    "margin-left": myvar + "px"

Or you can add class to the element.

    CSS Howto..

    How to make all cross browser compatible skewed div edges?

    How to adjust height based on content css

    How to set css class 'active' by using C#?

    How do prevent a div from resizing? [closed]

    How to generate a source map for minified CSS generated by dotless

    How to eliminate the overlap border using CSS only

    How to center the boxes as shown?

    How to make a CSS transform affect the flow of other elements

    How to add vertical gradient using css?

    How do I create CSS only tabs/pages with #hash URLs?

    Any Idea how this web site acheives a fluid/liquid layout [closed]

    How to make menu fold like paper using CSS?

    Give a box an ID, once clicked shows alert of that ID?

    How can I fix the indentation in a facebook like-box?

    how to auto adjust table td width from the content

    How to place divs with background-images in order with 100% width?

    How to set hyphenation at the end of word when to break word in CSS?

    How to pass an array from controller to PHP file that contains CSS before the view is loaded?

    How to adjust table or content in CSS when printing?

    How to make a automatic image slider.?

    How to improve this code to combine/compress CSS using PHP [closed]

    How make to flow around a triangular block?

    How does the arrival of HTML5 and CSS3 affect jQuery?

    HTML or CSS, how is this done? [closed]

    How do I scroll to s specific location in an iframe?

    several questions about how to work with divs

    How to add Jquery Mobile effects to dynamically added elements?

    How to divide parent div's height between child divs

    how to put inline image css in ghost-blog?

    How to toggle div and up-down arrow heads using css only