bntaizi 2014-07-25 02:42 采纳率: 25%
浏览 820

判断鼠标是否在层里,qwe2里的num是[object]














<br> var array1 = new Array();//将原始数据分割成数组<br> var arrays = new Array();//将array1中偶数项存入此数组<br> var num =&quot;&quot;; //记录当前点击的是第几个<a><br> var div = document.createElement(&quot;DIV&quot;);<br> div.id = &quot;aaa1&quot;;<br> div.style.backgroundColor = &quot;#9ef1fa&quot;;<br> div.style.borderLeft = &quot;5px outset #4ec5f5&quot;;<br> div.style.borderTop = &quot;5px outset #4ec5f5&quot;;<br> div.style.borderRight = &quot;2px outset #4ec5f5&quot;;<br> div.style.visibility = &quot;hidden&quot;;<br> div.style.position = &quot;absolute&quot;;<br> document.body.appendChild(div);</p> <pre><code> function getValue() { document.getElementById(&quot;textarea1&quot;).value = &quot;&quot;; array1.splice(0, array1.length); arrays.splice(0, arrays.length); var file = document.getElementById(&quot;textarea&quot;).value var a = file; do { var a = a.replace(&quot;[&quot;, &quot;\\&quot;); a = a.replace(&quot;]&quot;, &quot;\\&quot;); } while (a.indexOf(&quot;[&quot;) &gt; 0 || a.indexOf(&quot;]&quot;) &gt; 0) array1 = a.split(&quot;\\&quot;); var content = &quot;&quot;; for (var i = 0; i &lt; array1.length; i++) { if (i % 2 == 1) { var array = array1[i].split(&quot;/&quot;); if (arrays.length == 0) { arrays[0] = array; } else { arrays[arrays.length] = array; } } if (i % 2 == 0) { content += array1[i]; } else { content += &quot;&lt;a id=&quot; + &quot;\&quot;&quot; + parseInt(i / 2) + &quot;\&quot;&quot; + &quot; onclick=&quot; + &quot;\&quot;&quot; + &quot;qwe(&quot; + parseInt(i / 2) + &quot;)&quot; + &quot;\&quot;&quot; + &quot; onmouseleave=&quot; + &quot;\&quot;&quot; + &quot;qwe1(&quot; + parseInt(i / 2) + &quot;)&quot; + &quot;\&quot;&quot; + &quot; style=&quot; + &quot;\&quot;&quot; + &quot;color:Red;text-decoration:none&quot; + &quot;\&quot;&quot; + &quot;&gt;&quot; + arrays[parseInt(i / 2)][0] + &quot;&lt;/a&gt;&quot;; } } var a = document.createElement(&quot;&lt;span id=&#39;aaa3&#39;&gt;&quot;); a.innerHTML = content; window.textarea1.appendChild(a); } var timeOut = null; function qwe(evt) { num =evt; clearTimeout(timeOut); if (document.getElementById(&quot;aaa2&quot;) != null) { document.getElementById(&quot;aaa1&quot;).removeChild(document.getElementById(&quot;aaa2&quot;)); } if (document.getElementById(&quot;aaa2&quot;) != null) { var length = document.getElementById(&quot;aaa2&quot;).childNodes.length; for (var i = 0; i &lt; length; i++) { document.getElementById(&quot;aaa2&quot;).removeChild(document.getElementById(&quot;aaa2&quot;).childNodes[i]); break; } } else { var ul = document.createElement(&quot;ul&quot;); ul.id = &quot;aaa2&quot;; } var o = document.getElementById(&quot;aaa1&quot;); for (var i = 0; i &lt; arrays[evt].length; i++) { var li = document.createElement(&quot;&lt;li style=&#39;margin-right:20px; margin-left:-20px; list-style-type:none; padding:0px;cursor:pointer;&#39; onmouseover=&#39;qwe4(this)&#39; onmouseleave =&#39;qwe(this)&#39; onclick=&#39;qwe2()&#39;&gt;&quot;); li.innerHTML = arrays[evt][i]; ul.appendChild(li);; } o.appendChild(ul); var a = &quot;#&quot; + evt; var thisLi = $(a); showSubList(a); } function qwe4(o) { o.style.color = &quot;Green&quot;; } function qwe5(o) { o.style.color = &quot;Black&quot;; } function qwe1(evt) { var a = &quot;#&quot; + evt; var thisLi = $(a); timeOut = setTimeout(function () { hideSubList(thisLi); }, 1000); $(&quot;#aaa1&quot;).hover(function (e) { clearTimeout(timeOut); }, function () { clearTimeout(timeOut); timeOut = setTimeout(function () { hideSubList(thisLi); }, 100); }); } var showSubList = function (a) { var o = document.getElementById(&quot;aaa1&quot;); o.style.visibility = &quot;visible&quot;; $(&quot;#aaa1&quot;).css({ top: top, opacity: 0 }).show().stop().animate({ top: $(a).offset().top, left: $(a).offset().left + $(a).width(), opacity: 1 }); }; var hideSubList = function (thisli) { var o = document.getElementById(&quot;aaa1&quot;); o.style.visibility = &quot;hidden&quot;; }; function qwe2() { var text = event.srcElement.innerHTML; var curText = $(&quot;#aaa3&quot;).html(); alert(curText); var starta = &quot;&lt;A id=&quot; + num + &quot;&quot;; alert(starta); var startindex = curText.indexOf(starta); var enda = &quot;&lt;/a&gt;&quot;; var endindex = curText.indexOf(enda, startindex); var replaceText = &quot;&lt;a id=&#39;&quot; + num + &quot;&#39; onclick=&#39;qwe(&quot; + num + &quot;)&#39; onmouseleave=&#39;qwe1(&quot; + num + &quot;)&#39; style=&#39;color:Red;text-decoration:none&#39;&gt;&quot; + text + &quot;&lt;/a&gt;&quot;; var content = curText.substr(0, startindex) + replaceText + curText.substr(endindex + enda.length, curText.length - endindex - enda.length); window.textarea1.removeChild(document.getElementById(&quot;aaa3&quot;)); var a = document.createElement(&quot;span&quot;); a.id = &quot;aaa3&quot;; a.innerHTML = content; window.textarea1.appendChild(a); hideSubList(); } &lt;/script&gt; </code></pre> <p></body></p>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 易语言把MYSQL数据库中的数据添加至组合框
    • ¥20 求数据集和代码#有偿答复
    • ¥15 关于下拉菜单选项关联的问题
    • ¥20 java-OJ-健康体检
    • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
    • ¥15 使用phpstudy在云服务器上搭建个人网站
    • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
    • ¥15 vue3+express部署到nginx
    • ¥20 搭建pt1000三线制高精度测温电路
    • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况