jeudi 7 juillet 2016

jquery add new property to css function


Is there some way to adding new property name to css in jquery ? Something like transit which have a lot of new properties (duration,complete etc ) $o I need some like this:

var css_class ={
  class1 : {height:100,background:'#000'},
  //class2 ... etc
}
var my_property = function(value){
  $(this).css(css_class.value);
}

$('#element').css({
  width: '100px',
  my_property: 'class1'
});
//expected ... #element have width 100 also height and backround from class1
//I know it can be solved with a plugin like :
// .css(...).my_plpugin('my_property') but I dont want this 

Thank you.

EDITED: Because more people answer what I try with this? I have added more details in the example. The clearest question is: How the transit plugin (for example) have also other properties? (other than those of css) what is the mechanism (the way) to do this ? Thank you.


Aucun commentaire:

Enregistrer un commentaire