是否有可能 fadeIn , fadeOut 或onclick
函数的其他效果?
E.G。点击
<a href="#" onclick="document.getElementById('test').style.backgroundImage='url(img/test.jpg)'" ><span class="left">Test</span>></a>
在淡入淡出效果中改变背景?
答案 0 :(得分:0)
尝试添加此样式:
<style>
#test {
transition: background .1s linear;
-webkit-transition: background .1s linear;
-moz-transition: background .1s linear;
-o-transition: background .1s linear;
}
</style>
<a href="#" onclick="document.getElementById('test').style.backgroundImage='url(img/test.jpg)'" ><span class="left">Test</span>></a>
答案 1 :(得分:0)
<a href="javascript:changeBackground('img/test.jpg')"><span class="left">Test</span>></a>
<div id="test" style="display: none;"></div>
<script>
function changeBackground(src) {
var img = new Image();
img.src = src;
img.onload = function () {
$('#test').fadeIn();
}
}
</script>
您可以使用jQuery