标签:碰撞检测 元素 span jpg tle blog img alt cli
两个元素如图所示:
var L = ev.clientX - disX; var T = ev.clientY - disY; var L1 = L; var R1 = L + obj.offsetWidth; var T1 = T; var B1 = T + obj.offsetHeight; var L2 = oImg.offsetLeft; var R2 = L2 + oImg.offsetWidth; var T2 = oImg.offsetTop; var B2 = T2 + oImg.offsetHeight; if ( R1 < L2 || L1 > R2 || B1 < T2 || T1 > B2 ) { oImg.src = ‘1.jpg‘; } else { oImg.src = ‘2.jpg‘; }
标签:碰撞检测 元素 span jpg tle blog img alt cli
原文地址:http://www.cnblogs.com/2390624885a/p/5994278.html