Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在有转换和无转换的情况下执行相同的操作?_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 如何在有转换和无转换的情况下执行相同的操作?

Javascript 如何在有转换和无转换的情况下执行相同的操作?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,是否有任何解决方案可以使用带转换和不带转换的相同操作 css -webkit-transition: all 0.5s ease 0s; -moz-transition: all 0.5s ease 0s; -ms-transition: all 0.5s ease 0s; -o-transition: all 0.5s ease 0s; transition: all 0.5s ease 0s; jquery $("#transition").click(function(){ $(

是否有任何解决方案可以使用带转换和不带转换的相同操作

css

-webkit-transition: all 0.5s ease 0s;
-moz-transition: all 0.5s ease 0s;
-ms-transition: all 0.5s ease 0s;
-o-transition: all 0.5s ease 0s;
transition: all 0.5s ease 0s;
jquery

$("#transition").click(function(){
    $("#box-progress").css("left", "50%");
});
// This shoudn't show transition;
$("#no-transition").click(function(){
    $("#box-progress").css("left", "50%");
});
演示:-

将转换放在单独的类中,如:

.apply_transitions {
    /* .. */
    transition: all 0.5s ease 0s;
}
然后,您希望转换执行以下操作:

$("#box-progress").addClass("apply_transitions").css("left", "50%");
如果你不想要Transition,那么:

$("#box-progress").removeClass("apply_transitions").css("left", "50%");

这意味着默认情况下,除非添加
apply\u transitions
类,否则没有任何内容具有转换