Bug Tracker

Modify

Ticket #4461 (closed enhancement: wontfix)

Opened 4 years ago

Last modified 15 months ago

Support array input into .css to return an object of css properties

Reported by: dantman Owned by:
Priority: major Milestone: 1.4
Component: css Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:

Description

Discussion:  http://groups.google.com/group/jquery-dev/browse_thread/thread/49124146636e5bb1

.css currently supports: .css("name"); => "value" get .css("name", "value"); => jQuery(this) set .css({"name": "value"); => jQuery(this) set

This is an enhancement to support another form of css getting: .css(name?); => {"name":"value"} get

Under this suggestion, when .css() is given a single array as input it will iterate over that array return an object with the array items as keys, and corresponding css values as the values.

In essence: jQuery('<div style="background-color: red; color: white;" />').css(["background-color", "color"]); => { "background-color": "red", "color": "white" }

This enhancement is useful for grabbing multiple css values at once, as well since the output is an object suitable for passing back to .css it is also useful for creating a css object you can use to revert css changes or copy css values from one node to another.

Attachments

css-array-support.patch Download (581 bytes) - added by dantman 4 years ago.
Patch to add support for the enhancment

Change History

Changed 4 years ago by dantman

Patch to add support for the enhancment

comment:1 Changed 3 years ago by dmethvin

  • Component changed from unfiled to css

comment:2 Changed 3 years ago by ajpiano

  • Status changed from new to closed
  • Resolution set to wontfix

This could be accomplished by using jQuery.fn.map, and if you need it as part of jQuery.fn.css, you could easily duckpunch it in.

comment:3 Changed 2 years ago by snover

#7169 is a duplicate of this ticket.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.