PHP (20140508)

时间:2014-05-09 08:37:05   收藏:0   阅读:392

通过Ajax操作Dom:

bubuko.com,布布扣
 1 if(xmlHttp.readyState == 4){
 2             if(xmlHttp.status == 200){
 3                 var sobj = document.getElementById("suggest");
 4                 var str = xmlHttp.responseText.split("-");
 5                 var suggest = "";
 6                 if(str.length >0 && str[0].length > 0){
 7                     for(var i=0; i<str.length; i++){
 8                         suggest += "<div class=‘suggest_link‘ " +
 9                                 " onmouseover=\"this.className=‘suggest_link_over‘\" " +
10                                 " onmouseout=\"this.className=‘suggest_link‘\" >"+str[i]+"</div>"
11                     }
12                     sobj.innerHTML = suggest;
13                     sobj.style.display = "block";
14                 }else{
15                     sobj.style.display = "none";
16                 }
17             }
18         }
bubuko.com,布布扣

把数据库中的数据显示在界面上。

PHP (20140508),布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!