js点击后添加样式

点击i后 展开 文字切换为 收起或是实现.small中图片旋转角度
其实我只需要实现点击“收起”“展开” 文字变换就好了

<meta charset="utf-8">
<style>
img {
    width:80px;
    height:80px;
}
</style>
<i id="t">展开</i>
<img src="1.jpg" class="small" id="t2">
<script>
window.onload = function(){
    var t = document.getElementById("t"),
    i = document.getElementById("t2");
    t.status = 'c';
    i.deg = 0;
    t.onclick = function(){
        if('c' == t.status){
            return t.status = 'e', t.innerHTML = '收起';
        }else{
            return t.status = 'c', t.innerHTML = '展开';
        }
    }
    i.onclick = function(){
        return i.deg = i.deg + 45, i.style.transform = 'rotate('+i.deg+'deg)';
    }
}
</script>追问

我现在结构是这样 的问题是他已经有个id  è€Œä¸”已经有绑定onclick事件了

追答

你把我的那段click里面的代码拷贝到Effect这个函数里边不就得了。。。

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-06-11
不明白你要说的是什麼!
相似回答