Fil Fil - 3 months ago 16
CSS Question

Remove inline CSS in jQuery

This inline CSS is generated by jssor-slider,

position: absolute;
top: 0px;
left: 0px;
width: 1500px;
height: 700px;
transform-origin: 0px 0px 0px;
transform: scale(0.876644);


and I want to override it with,

position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 700px;


I tried it by the following,

$('#slider_container').width('100%');
$('#slider_container > div').css({'position': 'absolute', 'top': '0px', 'left':' 0px', 'width':' 10%', 'height':' 700px'});


I was successful, but this always remain.

transform-origin: 0px 0px 0px;
transform: scale(0.876644);


How to remove this using jQuery?

Answer

Just set the transform back to its default value. Which for transform is scale(1), and for transform-origin is 50% 50% 0.

jQuery

$('div').css({'transform': 'scale(1)', 'transform-origin': '50% 50% 0'});

JSFiddle (Before)

JSFiddle (After)