![](/img/trans.png)
[英]How can I make a 2D pattern with dots that can dissapear and reappear in p5js?
[英]Make <p> toggle reappear
我制作了一個查找工具,其中出現了一個項目列表,單擊該項目時菜單消失。 這可能是一個小小的修復
第一次很好用,但是隨后查找工具不起作用。
首先,在帶有div的文本框中鍵入您的項目,該div會查找:
<input type="text" name="item" id="item" onkeyup="showResult(this.value)" placeholder="Enter Item Number" autocomplete="off">
<div id="lookup"></div>
我的物品看起來像這樣:
<p><a href=# onclick=\"xmlhttpPost(lookup string and target div)>Item</a></p>
我使用此腳本使該項目在單擊后消失:
$(document).ready(function () {
$('#lookup').on({
click: function () { $('#lookup').toggle();
return false; }
}, 'a');
});
第一次運行良好,但此后永久隱藏了查找。
這是編輯的查找代碼:
function showResult(str,itemnum)
{
if (str.length==0)
{
document.getElementById("lookup").innerHTML="";
document.getElementById("lookup").style.border="0px";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("lookup").innerHTML=xmlhttp.responseText;
document.getElementById("lookup").style.border="1px solid #A5ACB2";
}
}
var e = document.getElementById("location");
var location = e.options[e.selectedIndex].value;
xmlhttp.open("GET","sql/lookup.php?category="+location+"&name="+str,true);
xmlhttp.send();
}
我要包裝這個項目,但這是最后一個小解決方案。 提前致謝。
如果您要做的只是清除單擊時的查找內容,則不要隱藏整個元素,只需將其清空即可:
$('#lookup').on({
click: function ()
{
$('#lookup').empty();
return false;
}
}, 'a');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.