多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
### **jQuery基础知识篇之小图片切换** #### **HTML的代码如下所示:** ~~~ <div class="niming"> <img src="img/no.png" onclick="changImg()" id="changimg"> <span>匿名评价</span> </div> ~~~ ###** css代码如下所示:** ~~~ /*匿名评价*/ .niming { position: relative; width: 100%; height: 30px; padding-left: 10px; } .niming #changimg { position: absolute; top: 0; left: 10px; margin-top: 6px; width: 18px; line-height: 30px;; } .niming img+span { position: absolute; top: 0; left: 35px; display: inline-block; height: 30px; line-height: 30px; } ~~~ jQuery的代码如下所示: ~~~ function changImg() { var imgObj = document.getElementById("changimg"); if(imgObj.getAttribute("src",2)== "img/no.png") { imgObj.src = "img/yes.png"; }else { imgObj.src = "img/no.png"; } } ~~~