Hey there! any question in your mind? Ask It Now!.

Popular Categories





i want css gradient to an element which is dynamic in JQuery.

+4 votes
94 views
asked in Programming by sunny (360 points)
edited by sunny

i am trying this 

$(".cpick-s").css({
  "background": "-moz-linear-gradient(top, rgba(128,128,128,1) 0%,
   rgba(255,0,4,1) 100%)"
  "background": "-webkit-gradient(linear, left top, left bottom, 
  color-stop(0%,rgba(128,128,128,1)), color-stop(100%,rgba(255,0,4,1)))"
  "background": "-webkit-linear-gradient(top, rgba(128,128,128,1) 0%,
   rgba(255,0,4,1) 100%)"
  "background": "-o-linear-gradient(top, rgba(128,128,128,1) 0%,
   rgba(255,0,4,1) 100%)"
  "background": "-ms-linear-gradient(top, rgba(128,128,128,1) 0%,
   rgba(255,0,4,1) 100%)"
  "background": "linear-gradient(to bottom, rgba(128,128,128,1) 0%,
   rgba(255,0,4,1) 100%)"
  "background": "filter: progid:DXImageTransform.Microsoft.gradient
  (startColorstr='#808080', endColorstr='#ff0004',GradientType=0 )"
});

1 Answer

+1 vote
answered by mika (1,290 points)
selected by sunny
 
Best answer

you can use this in CSS

.gradient {
    background: -moz-linear-gradient(top, rgba(128,128,128,1) 0%, rgba(255,0,4,1) 100%);
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(128,128,128,1)), color-stop(100%,rgba(255,0,4,1)));
  background: -webkit-linear-gradient(top, rgba(128,128,128,1) 0%,rgba(255,0,4,1) 100%);
  background: -o-linear-gradient(top, rgba(128,128,128,1) 0%,rgba(255,0,4,1) 100%);
  background: -ms-linear-gradient(top, rgba(128,128,128,1) 0%,rgba(255,0,4,1) 100%);
  background: linear-gradient(to bottom, rgba(128,128,128,1) 0%,rgba(255,0,4,1) 100%);
  background: filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#808080', endColorstr='#ff0004',GradientType=0 );
}
 
.my-div {
    width:  50px;
    height: 50px;
}
}
$(function () {
    $('.my-div').addClass('gradient'); 
});
I hope you got the point.

Related Questions

+1 vote
2 answers 89 views

Not a Member yet?

Ask to Folks Login

My Account
260 Folks are online
8 members and 252 guest online
Your feedback is highly appreciated