Javascript 通过单击按钮旋转图像
我想在点击按钮时将图像旋转90度、180度和360度Javascript 通过单击按钮旋转图像,javascript,jquery,Javascript,Jquery,我想在点击按钮时将图像旋转90度、180度和360度 <img class="test" id="image" src="images/image" alt="This is the Display Image" /> 或者,您也可以使用CSS 3来实现相同的目标 #div:focus { transform: rotate(90deg); -ms-transform: rotate(90deg); -webkit-transform: rotate(90deg);
<img class="test" id="image" src="images/image" alt="This is the Display Image" />
或者,您也可以使用CSS 3来实现相同的目标
#div:focus
{
transform: rotate(90deg);
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
}
小提琴:
**如果您想合并动画,请查看JQuery animate函数,试试这个,我希望它会有所帮助 HTML
<img class="test" id="image" src="http://fbhunt.com/images/FBHUNT200.png" alt="This is the Display Image" />
<input type="button" value="click" id="clickme">
试试这个。我希望这会对您有所帮助。我希望在单击按钮时使用此功能,并希望在各个方向旋转图像。您对此有什么想法吗?您可以使用CSS 3动画(用于多次旋转)>>style.display='none'>>function show(){document.getElementById(“thing”).style.display=“inline”}>单击后将其更改为inline!嗯。。。我是一名mac开发人员,通常不会经常使用IE。。。尝试查看ie对哪些函数有问题(
hasClass
或attr
)并查看是否存在工作区(可能可以使用attr(classname)
而不是hasClass(classname)
,如果是问题,或者它们可能是类()
您可以使用而不是attr('class',value)
)
$('input').click(function(){
var img = $('img');
if(img.hasClass('north')){
img.attr('class','west');
} else if(img.hasClass('west')){
img.attr('class','south');
} else if(img.hasClass('south')){
img.attr('class','east');
} else if(img.hasClass('east')){
img.attr('class','north');
}
});
<img class="test" id="image" src="http://fbhunt.com/images/FBHUNT200.png" alt="This is the Display Image" />
<input type="button" value="click" id="clickme">
$(document).ready(function() {
$(document).on('click','#clickme',function(){
$("#image").css({'transform': 'rotate(90deg)'});
});
});