gpt4 book ai didi

jquery - 使用 Jquery 变量更改 CSS 属性

转载 作者:太空宇宙 更新时间:2023-11-04 12:03:37 24 4
gpt4 key购买 nike

我正在尝试使用 Jquery 更改 css。 css 属性有点复杂,所以我不确定我的连接是否有效或者是否存在其他问题:

JQUERY:

$(document).ready(function() {

var degrees = Math.floor(Math.random() * 151) + 20; //this is my variable

$('#p2').css("-webkit-transform","rotate("+degrees"deg)");
// this -webkit-transform: rotate(50deg); is the property im trying to change
});

最佳答案

有个小错误。你没有正确附加它。注意度数后的“+”

$(document).ready(function() {

var degrees = Math.floor(Math.random() * 151) + 20; //this is my variable

$('#p2').css("-webkit-transform","rotate("+ degrees +"deg)");
// this -webkit-transform: rotate(50deg); is the property im trying to change
});

关于jquery - 使用 Jquery 变量更改 CSS 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29551052/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com