3

i want to add the transform: scale() property using Javascript. but for transform prefix not working :

var $square = $('#homepage');
$square.css('zoom', r);
$square.css('-moz-transform', 'scale(' + r + ')');
$square.css(  '-o-transform', 'scale(' + r + ')'); 

3 Answers 3

3

Try this

element.style.webkitTransform = "";
element.style.MozTransform = "";
element.style.msTransform = "";
element.style.OTransform = "";
element.style.transform = "";

Or jquery:

$(element).css({
    "webkitTransform":"",
    "MozTransform":"",
    "msTransform":"",
    "OTransform":"",
    "transform":""
});
Sign up to request clarification or add additional context in comments.

1 Comment

not sure why no-one has upvoted you before. this works a treat for me across all major browsers (tests successfully back to IE9 inclusive)
2

Try using something like this:

element.style.webkitTransform = "scale()";

3 Comments

how about with -moz-, -o- ?
Isn't it invalid to have scale with no parameter?
replace the webkitTransform with Moz or MS etc... and the scale() was just an example, i think he knows to add the parameter back in :)
0

Since jQuery 1.8, there is no need to include vendor prefixes - jQuery will do this automatically, if required. Vendor prefixes are becoming less required as support for CSS3 increases.

If you are using < 1.8, then you probably need to manually amend the style attribute.

var $h = $('#h');
$h.css({
    background:'#f00'
});
var s = $h.attr('style');
s += '-moz-transform: scale(2);';
$h.attr('style',s);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.