javascript - Opposite of jQuery.camelCase for CSS property names -


jquery.camelcase used convert dashed css properties camelcased cssom(? or dom?) properties.

i'd opposite dynamically create css transition value.

i don't want use all keyword this. i'd make possible not force coder use background-color instead of backgroundcolor.

is possible (maybe via jquery) or take lots of code cross browser support?

edit:

$("#example").css("transition-property", "backgroundcolor") // fail 

i don't want same in example shows problem.

i'm trying iterate through object contains css properties , values set objects keys transition-properties. e.g. { backgroundcolor: "red" } should set background-color transition-property instead of backgroundcolor.

a simple function job is:

function decase(s) {     return s.replace(/[a-z]/g, function(a) {return '-' + a.tolowercase()}); }  alert(decase('scrollbardarkshadowcolor')); // scrollbar-dark-shadow-color 

there many other ways.

also, can camelcase using:

function camelcase(s) {     return s.replace(/-(.)/g, function(a, $1){return $1.touppercase();}); } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -