Javascript变量不在-webkit转换中工作

Javascript变量不在-webkit转换中工作,javascript,jquery,css,rotation,transform,Javascript,Jquery,Css,Rotation,Transform,这是我的密码: <head> <meta charset="utf-8"> <title>Untitled Document</title> <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> <script src="http://code.jquery.com/jquery-latest.min.js" type=

这是我的密码:

<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="http://code.jquery.com/jquery-latest.min.js"
        type="text/javascript"></script>


<style>
body {
    text-align: center;
    width: 100%;}

#container {
transform: rotate(30deg);
transform-origin: bottom center;
-ms-transform: rotate(30deg); /* IE 9 */
-ms-transform-origin: bottom center;
-webkit-transform: rotate 0deg; /* Safari and Chrome */
-webkit-transform-origin:bottom center;
border: 1px solid black;
width: 152px;
margin: 40px auto;
height: 244px;
overflow: visible;
}
</style>

<script>      
var meteo = (function () {
    var meteo = null;
    $.ajax({
        'async': false,
        'global': false,
        'url': "http://api.openweathermap.org/data/2.5/weather?q=Leicester&units=metric",
        'dataType': "json",
        'success': function (data) {
            meteo = data;
        }
    });
    return meteo;
})(); 

var vento_forza = meteo.wind.speed;
var vento_direzione = meteo.wind.deg+"deg";    
</script>
</head>

<body>
<div id="container">
    <svg version="1.1" id="indicator" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="152px" height="244px" viewBox="0 0 152 244" enable-background="new 0 0 152 244" xml:space="preserve">
    <polygon fill="#84FFFB" points="0,244 76,207 152,244 "/>
    <polygon fill="#D6F4FF" points="76,0 76,207 152,244 "/>
    <polygon fill="#00A5EC" points="76,0 76,207 0,244 "/>
</svg>
</div>

<script>

function direzione(){
    document.getElementById("container").style.webkitTransform = "rotate(vento_direzione)"
}
</script>
<input type="button" onclick="direzione()" value="Change link">
</body>
</html>
基本上,我希望容器div的旋转随着var vento_direzione的变化而变化,这是一个从api请求中获得的数字,每当我单击按钮时,我都会添加deg字符串;遗憾的是,这似乎没有发生。如果我只是在函数中传递一个值,而不是var,那么一切都正常。我做错了什么

请帮忙!干杯

你想要什么

document.getElementById("container").style.webkitTransform = "rotate("+vento_direzione+")";
因为您只是试图将文本字符串RotateEvento_direzione传递给它,所以当变量在这样的字符串中时,它们不会被替换为它们的值


因此,您需要做的是连接实际的字符串部分旋转,并使用vento_direzione变量:rotate+vento_direzione+是字符串连接

非常好!现在它起作用了,谢谢!你能解释一下这些是做什么用的吗?为什么传递存储在var中的字符串是不正确的?@AndreaLigios,他感谢我,但我删除了我的评论,并将其作为解释他需要的字符串连接的答案。Mistery解决了:D@Neurone ora dovresti accettare la Rispesta cliccando sulla V bianca nell'angolo在stessa中北方向的中北方向……啊哈,我不是疯了,我为拼写错误感到抱歉。谢谢大家。