jquery的hover方法不能用"_"开头

本文介绍了一个使用jQuery hover方法在Internet Explorer浏览器中遇到的问题,即无法更改元素背景色。通过调整CSS类名的方式成功解决了该兼容性问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天用jquery 的 hover 方法的时候,在火狐上正常,在IE上不会改变背景色。。。

 

Html代码:  
  1. <style type="text/css">  
  2.         ._hover {background-color: gray;}  
  3. </style>  

 jquery代码:

为了避免冲突,我在hover前面加了_,即: _hover作为class

Js代码:  
  1. $("#_content tr").hover(  
  2.               function () {  
  3.                 $(this).addClass("_hover");  
  4.               },  
  5.               function () {  
  6.                 $(this).removeClass("_hover");  
  7.               });  

 但是却导致了FF正常,IE不正常。

后来实在想不通,就改了一下class,把_去掉试试,果然是这个原因。。。尼玛

 

Html代码:  
  1. <style type="text/css">  
  2.         .hover {background-color: gray;}  
  3.     </style>  
Js代码:  
  1. $("#_content tr").hover(  
  2.               function () {  
  3.                 $(this).addClass("hover");  
  4.               },  
  5.               function () {  
  6.                 $(this).removeClass("hover");  
  7.               });  

 OK。。。

原文链接:http://www.software8.co/wzjs/jquery/3320.html

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <% request.setCharacterEncoding("utf-8"); String contextPath = request.getContextPath(); %> <!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>添加行政区划</title> <script type="text/javascript" src="<%=contextPath%>/js/comm/jquery-1.4.4.min.js"></script> <link href="<%=contextPath%>/css/min/insect_spore.css" rel="stylesheet" type="text/css" /> <link href="<%=contextPath%>/css/newxingyou/dialog.css" rel="stylesheet"> <style type="text/css"> body, html, #allmap { width: 100%; height: 100%; overflow: hidden; margin: 0; font-family: "微软雅黑"; } #result { width: 100%; font-size: 12px; } .z_index_8 { z-index: 8; } .z_index_99 { z-index: 80; } </style> <link rel="stylesheet" href="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.css" /> <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=5MPXqVijsfPNiFQdifGtUNT7c9ekGkMF"></script> <script type="text/javascript" src="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.js"></script> <style> Dialog{ height: 100vh; width: 100vw; } #mcgOptate{ display: flex; justify-content: space-around; } #mcgOptate button{ color: red; border: none; background-color: inherit; } .tab { display: flex; background-color: #fff; border-radius: 5px; overflow: hidden; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); } .tab button { background-color: #f2f2f2; color: #333; border: none; outline: none; cursor: pointer; padding: 10px 20px; flex: 1; transition: all 0.3s ease-in-out; } .tab button.active, .tab button:hover { background-color: #3498db; color: #fff; } .tab button:hover{ background-color:#2ebb35; } .tabcontent { display: none; padding: 20px; border: 1px solid #ccc; border-top: none; border-radius: 0 0 5px 5px; background-color: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); overflow: auto; height: 100vh; } table { width: 100%; border-collapse: collapse; /* background: linear-gradient(to right, #ff416c, #ff4b2b);*/ border: 1px solid #333; border-radius: 10px; } th, td { padding: 5px; text-align: center; color: black; font-weight: bold; border: 1px solid blue; } th { background-color: #f25d11; } td { background-color: rgba(0, 150, 0,.2); } tr:nth-child(2n) { background-color: rgba(0, 148, 255,.8); } .pagination { display: inline-block; margin-bottom: 20px; } .pagination a { color: black; float: left; padding: 8px 16px; text-decoration: none; transition: background-color .3s; } .pagination a.active { background-color: dodgerblue; color: white; } .pagination a:hover:not(.active) { background-color: #ddd; } </style> </head> <body> <input type="hidden" id="areaName" name="areaName" value="${areaName }"> <input type="hidden" id="siteName" name="siteName" value="${siteName }"> <input type="hidden" id="_aliasname" name="_aliasname" value="${_aliasname }"> <input type="hidden" id="centerSiteIp_Aliasname" name="centerSiteIp_Aliasname" value="${centerSiteIp_Aliasname }"> <input type="hidden" id="siteid" name="siteid"> <input type="hidden" id="contextPath" name="contextPath" value="<%=contextPath%>"> <div id="body_div" style="width: 100%; height: 100%; border: 1px solid #aaa;"> <div style="width: 100%; height: 20px; background: #eee; border: 1px solid #ccc; padding: 5px;"> 当前位置->性诱信息->地图GIS标记 <!-- 【共有<span id="_pointCount">0</span>个站点】 --> </div> <div id="allmap"></div>//用于挂栽地图 <img id="loading_Img" src="<%=contextPath%>/images/min/loading_ill1.gif" class="loading_Img" /> <%-- 表格操作按钮--%> <div style="display: none"> <div id="mcgOptate"> <button onclick="DataAn(this)">数据分析</button> </div> </div> <div id="DivLocker" class="hid_div" hidden="hidden"></div> <div id="mcgDialog"> <div class="overlay" id="overlay"></div> <div class="draggable-window" id="draggable"> <div class="draggable-header" > <div class="header-title">性诱信息</div> <span class="close-button" onclick="closeWindow()">×</span> </div> <div class="draggable-content" style="overflow: hidden"> </div> </div> </div> </div> <div id="mcgcDialog"> </div> <script src="<%=contextPath%>/css/newxingyou/draggableWindow.js"> </script> <script type="text/javascript"> var areaName; var pointArr; // 百度地图API功能 var map = new BMap.Map("allmap", { minZoom : 5, maxZoom : 26 }); // 创建Map实例,设置地图允许的最小/大级别 // 添加带有定位的导航控件 var navigationControl = new BMap.NavigationControl({ // 靠左上角位置 anchor : BMAP_ANCHOR_TOP_LEFT, // LARGE类型 type : BMAP_NAVIGATION_CONTROL_LARGE // 启用显示定位 //enableGeolocation: true }); map.addControl(navigationControl); var mapType1 = new BMap.MapTypeControl({ mapTypes : [ BMAP_NORMAL_MAP, BMAP_HYBRID_MAP ] }); var overView = new BMap.OverviewMapControl(); //var overViewOpen = new BMap.OverviewMapControl({ // isOpen : true, // anchor : BMAP_ANCHOR_BOTTOM_RIGHT //}); //添加地图类型和缩略图 map.addControl(mapType1); //2D图,卫星图 map.addControl(overView); //添加默认缩略地图控件 //map.addControl(overViewOpen); //右下角,打开 function getMapPoint() { var areaName = $("#areaName").val(); var centerSiteIp_Aliasname = $("#centerSiteIp_Aliasname").val(); $("#loading_Img").hide(); var points = eval("(" + '${list}' + ")"); //$("#_pointCount").text(pointArr.length); var point; if (points.length > 0 && points.length != "undefined") { var point = new BMap.Point(points[0].x, points[0].y); if (areaName == '国家') { map.centerAndZoom(point, 4); } if (areaName != '国家') { map.centerAndZoom(point, 8); } } else { point = new BMap.Point(105.680507, 34.865556); map.centerAndZoom(point, 4); alert("该地区暂无安装设备"); } map.enableScrollWheelZoom(); getBoundary(areaName, points); } setTimeout(function() { getMapPoint(); }, 500); function getBoundary(areaName, pointArr) { var bdary = new BMap.Boundary(); if (areaName != '国家') { bdary.get(areaName, function(rs) { //获取行政区域 map.clearOverlays(); //清除地图覆盖物 var count = rs.boundaries.length; //行政区域的点有多少个 for (var i = 0; i < count; i++) { var ply = new BMap.Polygon(rs.boundaries[i], { strokeWeight : 5, strokeColor : "#ff0000" }); //建立多边形覆盖物 ply.setFillColor("");//设置多边形的填充颜色,参数为合法的CSS颜色值。当参数为空字符串时,折线覆盖物将没有填充效果。 //ply.setFillOpacity(""); //设置多边形的填充透明度,取值范围0 - 1。 map.addOverlay(ply); //添加覆盖物 //map.setViewport(ply.getPath()); //调整视野 } getJsonData(pointArr); }); } else { getJsonData(pointArr); } } function getJsonData(pointArr) { for (var i = 0; i < pointArr.length; i++) { var _point = pointArr[i]; var site_name = _point.subSiteName; addMarker(_point); } } // 编写自定义函数,创建标注并绑定点击时间 function addMarker(_point) { var point = new BMap.Point(_point.x, _point.y); var marker = new BMap.Marker(point); var onlinestate = _point.onlinestate; var iconImg =""; if(onlinestate=="True"){ iconImg = $("#contextPath").val() + "/images/map/green.png"; }else{ iconImg = $("#contextPath").val() + "/images/map/gray.png"; } var myIcon = new BMap.Icon(iconImg, new BMap.Size(19, 25)); var marker = new BMap.Marker(point, { icon : myIcon, title: "(经度:"+_point.x+",纬度:"+ _point.y+")" }); //创建marker对象 marker.addEventListener("click", function(e) { infoWindowFun(this, _point); }); var opts = { position : point, // 指定文本标注所在的地理位置 offset : new BMap.Size(15, -15) //设置文本偏移量 }; var label = new BMap.Label(_point.subSiteName, opts); // 创建文本标注对象 label.setStyle({ color : "red", fontSize : "12px", height : "20px", lineHeight : "20px", fontFamily : "微软雅黑" }); map.addOverlay(label); map.addOverlay(marker); } function ShowImg(url){ const img=document.querySelector(".menv #showImg") img.addEventListener('click',()=>{ window.parent.frames["leftFrame"].location.href = url; this.closeWindow() $("#loading_Img").show(); }) } function infoWindowFun(_this, _point) { if (_point.id === 189) { window.parent.frames["mainFrame"].location.href = '<%=contextPath%>/comm/sqweb/shangqing.jsp'; return; } if (_point.id === 190) { window.parent.frames["mainFrame"].location.href = '<%=contextPath%>/comm/sqweb/shangqing2.jsp'; return; } if (_point.id === 191) { window.parent.frames["mainFrame"].location.href = '<%=contextPath%>/comm/sqweb/shangqing3.jsp'; return; } if (_point.id === 192) { window.parent.frames["mainFrame"].location.href = '<%=contextPath%>/comm/sqweb/shangqing4.jsp'; return; } var onlinestate = _point.onlinestate; var siteid = _point.id; var pointX = _point.x; var pointY = _point.y; var _aliasname = _point.aliasname; $("#siteName").val(_point.subSiteName); $("#_aliasname").val(_aliasname); var content = ""; if (onlinestate == "True") { var getRealDataUrl = $("#contextPath").val() + "/min/newxingyou/get/Shebei/?SiteId="+ siteid + "&ShebeiModel=xy" $.ajax({ url : getRealDataUrl, timeout : 30000, type : 'GET', cache : false, ifModified : true, beforeSend : function(xmlHttp) { $("#loading_Img").show(); xmlHttp.setRequestHeader("If-Modified-Since", "0"); xmlHttp.setRequestHeader("Cache-Control", "no-cache"); }, success : function(data) { if(JSON.parse(data).length>0){ //跳转页面 window.parent.frames["mainFrame"].location.href = $("#contextPath").val()+"/min/newxingyou/xingyou?siteid="+siteid+"&ShebeiList=" } else { $("#loading_Img").hide(); content = '<div style="margin:0;line-height:20px;padding:2px;">' + '<h4 style="margin:10px 0 5px 0;padding:0.2em 0">' + _point.subSiteName + '</h4>' + '对不起,暂无数据...' + '</div>'; var infoWindow = new BMap.InfoWindow(content); // 创建信息窗口对象 _this.openInfoWindow(infoWindow); } } }); } else { content = '<div style="margin:0;line-height:20px;padding:2px;">' + '<h4 style="margin:10px 0 5px 0;padding:0.2em 0">' + _aliasname + '</h4>' + '对不起,该站点未连接。' + '</div>'; var infoWindow = new BMap.InfoWindow(content); // 创建信息窗口对象 _this.openInfoWindow(infoWindow); } } function showChangeDiv(url) { $("#cheackImg").val(url); //getMapPoint(); $('#DivLocker').addClass("z_index_99"); $('#DivLocker').show(); setTimeout(function() { $("#DHABGE_DIV").show(); }, 500); } function hideChangeDiv() { debugger $('#DivLocker').removeClass("z_index_99"); var _class = $('#DivLocker').attr("class"); if (_class == "hid_div") { $('#DivLocker').hide(); } $("#DHABGE_DIV").hide(); } function FunCheackImg() { debugger var url = $("#cheackImg").val(); window.parent.frames["leftFrame"].location.href = url; } function FunShowDetailDiv() { hideChangeDiv(); $('#DivLocker').addClass("z_index_99"); $('#DivLocker').show(); $("#DETAIL_DIV").show(); var siteName = $("#siteName").val(); var _aliasname = $("#_aliasname").val(); var iframSrc = $("#iframSrc").val(); iframSrc = iframSrc + "?siteName=" + encodeURI(siteName) + "&_aliasname=" + _aliasname; $("#light_form").attr("src", iframSrc); } function FunHideDetailDiv() { $('#DivLocker').removeClass("z_index_99"); var _class = $('#DivLocker').attr("class"); if (_class == "hid_div") { $('#DivLocker').hide(); } $("#DETAIL_DIV").hide(); } </script> </body> </html> 设置点击地图上任意监测点都显示</h4>' + '对不起,暂无数据...' + '</div>';
06-22
<?php include './include/class.main.php'; include './save/config.php'; include './save/top.inc.php'; $skin=array( 'color'=>'#50b2c8', //文本颜色 'input_border'=>'#6599aa', //搜索边框颜色 'input_color'=>'white', //搜索文本颜色 'background'=>'#0f3854', //背景颜色 'background_style'=>'#0a2e38 0%,#000000 80%', //背景渐变样式 ); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="renderer" content="webkit"/> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/> <script type="text/javascript" src="./include/jquery.min.js"></script> <script type="text/javascript" src="./include/class.main.js" ></script> <link href="./include/jquery.autocomplete.css" rel="stylesheet"> <script type="text/javascript" src="./include/jquery.autocomplete.js?ver=1.2"></script> <title><?php echo $CONFIG["TITLE"]; ?></title> <style> html,body{ overflow:auto !important; width:100%; height: 100%; margin: 0; padding: 0; } body{ text-align: center; background: <?php echo $skin["background"];?>; background: -webkit-radial-gradient(<?php echo $skin["background_style"];?>); /* Safari 5.1-6.0 */ background: -o-radial-gradient(<?php echo $skin["background_style"];?>); /* Opera 11.6-12.0 */ background: -moz-radial-gradient(<?php echo $skin["background_style"];?>); /* Firefox 3.6-15 */ background: radial-gradient(<?php echo $skin["background_style"];?>); /* 标准语法 */ background-size: 100%; } p { margin: 0; padding: 0; } a{ color:<?php echo $skin["color"]; ?>; } #clock { font-family: 'Share Tech Mono', monospace; text-align: center; color: #daf6ff; /* text-shadow: 0 0 20px #0aafe6, 0 0 20px rgba(10, 175, 230, 0); */ } #clock .time { letter-spacing: 0.05em; font-size: 60px; padding: 5px 0; } #clock .date { letter-spacing: 0.1em; font-size: 15px; } #clock .text { letter-spacing: 0.1em; font-size: 12px; padding: 20px 0 0; } #word{ background: #fff; color: #000; max-height:170px; overflow-y:auto; overflow-x:hidden; } #main{ text-align: center; background-size: cover } h1{ color:red;} h2{color:green;} h3{color:#a7e9c3} h4{color:blue;font-size:50px} *{ box-sizing: border-box;} div.search {padding: 5px 0;} form { position: relative; width: 300px; margin: 0 auto; } input, button { border: none; outline: none; color:<?php echo $skin["input_color"]; ?>; } input { width: 100%; height: 42px; padding-left: 13px; } button { height: 42px; width: 42px; cursor: pointer; position: absolute; } /*搜索框6*/ .bar6 input { background: transparent; border-radius:3px; border:2px solid <?php echo $skin["input_border"]; ?> ; top: 0; right: 0; } .bar6 button { background:<?php echo $skin["input_border"]; ?>; border-radius: 0 5px 5px 0; width: 60px; top: 0; right: 0; } .bar6 button:before { content: "搜索"; font-size: 13px; color: <?php echo $skin["input_color"] ?>; } /* 搜索内容样式 */ .list_btn{ display: inline-block; text-decoration: inherit; /* 内外边距及宽高属性 */ margin: 1%; padding: 5px; height: 30px; min-width:31%; max-width:95%; /* 文字及边框属性 */ color:<?php echo $skin["color"]; ?>; font-size:13px; border-radius: 5px; border: 2px solid <?php echo $skin["color"]; ?>; /* 文字剪裁 */ text-overflow: ellipsis; overflow: hidden; white-space: nowrap !important; outline: 0 !important } /* 移动设备自适应宽高 */ @media screen and (max-width: 650px){.list_btn{min-width:95%;}} /*清除浮动代码*/ .clearfloat{clear:both} .resou{ padding-top: 15px; } .resou a{ color:<?php echo $skin["color"] ?>; padding: 5px; text-decoration:none; } a{text-decoration:none;} </style> <script> function check_str(field){ with(field){ var arr=['{','}','(',')','=',',',';','"','<','>','script','iframe','@','&','%','$','#','*',':','.','if','/','\\']; if("<?php echo $CONFIG["socode"]["not_off"];?>"=='1'){ var str="<?php echo base64_decode($CONFIG["socode"]["not_val"]); ?>"; if(str!=''){strs = str.split("|");arr = arr.concat(strs);} } for (var key in arr) { if( value.toLowerCase().indexOf(arr[key].toLowerCase()) > -1){ return true; } } return false; } } function validate_form(thisform){ with(thisform){ if(wd.value.indexOf('http')===-1){action='./so.php';wd.name='wd'}else{action='./';wd.name='url';} if(typeof wd!=="undefined" && wd.name=='wd'){ if (check_str(wd)){ alert("请勿输入非法字符!"); return false } } } } </script> <!--<script type="text/javascript" src="../../../include/jquery.min.js"></script>--> <script> // 检查是否为移动设备 function isMobileDevice() { return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); } // 加载随机背景图片 function loadRandomBackground() { if(isMobileDevice()) { var backgroundURL = './208896.jpg' } else { backgroundURL = './208899.jpg' } console.log(backgroundURL) // 设置body的背景图片为随机图片 $('body').css('background', 'url(' + backgroundURL + ') no-repeat center center fixed'); $('body').css('background-size', 'cover'); } // 页面加载时加载随机背景 $(document).ready(function() { loadRandomBackground(); }); </script> </head> <body> <div id="clock"> <div id="main"></div> <div class="clearfloat"></div> <div id='body'> <p class="date"></p> <p class="time" id="time">00:00:00</p> <p class="text" id="text">2018-08-08 星期一</p><br> <div class="search bar6"> <form target="_parent" action="./" onsubmit="return validate_form(this);" method="get" > <input id="wd" type="text" name="v" placeholder="请输入视频名称或视频链接" value="<?php echo $_GET['wd']; ?>" > <button type="submit"></button> <div id="word" ></div> </form> <?php if($CONFIG["socode"]["top_off"]): ?> <div class="resou" id="socode_top"> <font face="verdana" style="color:<?php echo $skin["color"] ?>;"> 热门搜索:</font> <?php arsort($TOPDATA);$i=0; foreach ($TOPDATA as $key=>$val ): ?> <a target='_parent' href="./so.php?wd=<?php echo rawurlencode($key); ?>" title='人气:<?php echo $val; ?>℃'><?php echo $key; ?></a> <?php $i++; if($i==5){break;}?> <?php endforeach; ?> <a target='_parent' href="javascript:void(0);" onclick="echotop();">更多...</a> </div> <?php endif; ?> <?php if($CONFIG["socode"]["diy_off"]): ?> <div id="socode_diy"> <br/> <?php echo base64_decode($CONFIG["socode"]["diy_val"]); ?> </div> <?php endif; ?> </div> <script id="LA-DATA-WIDGET" crossorigin="anonymous" charset="UTF-8" src="https://v6-widget.51.la/v6/JmppOQcqqd5xRMl7/quote.js?theme=#0EEBF2,#333333,#04F2EA,#333333,#FFFFFF,#1690FF,12&f=12&display=0,1,0,1,0,1,0,1"></script> <?php if($CONFIG["FOOTER_LINK"]['off']): ?> <div id="footer_link"> <br/> <font face="verdana" style="color:<?php echo $skin["color"] ?>;"> 友情链接:</font> <?php foreach( $CONFIG["FOOTER_LINK"]['info'] as $key=>$val) : ?> <a target='_blank' href="<?php echo $val; ?>" ><?php echo $key; ?></a> <?php endforeach; ?> </div> <?php endif; ?> <br><span id="sitetime"> </span><br> <br><div id="footer" ></div> </div> </div> <script> //显示日期时间 var week = ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']; var timerID = setInterval(updateTime, 1000); var sitetime="<?php echo $CONFIG["sitetime"];?>"; updateTime(); function updateTime() { var cd = new Date(); $('#time').text(zeroPadding(cd.getHours(), 2) + ':' + zeroPadding(cd.getMinutes(), 2) + ':' + zeroPadding(cd.getSeconds(), 2)); $('#text').text(zeroPadding(cd.getFullYear(), 4) + '-' + zeroPadding(cd.getMonth()+1, 2) + '-' + zeroPadding(cd.getDate(), 2) + ' ' + week[cd.getDay()]); SiteTime(sitetime); }; function zeroPadding(num, digit) { var zero = ''; for(var i = 0; i < digit; i++) { zero += '0'; } return (zero + num).slice(-digit); } //网站运行时间 function SiteTime(time){ var seconds =1000; var minutes = seconds *60; var hours = minutes *60; var days = hours *24; var years = days *365; var dateBegin = new Date(time.replace(/-/g, "/"));//将-转化为/,使用new Date var dateEnd = new Date();//获取当前时间 var diff = dateEnd.getTime() - dateBegin.getTime();//时间差的毫秒数; var diffYears =Math.floor(diff/years); var diffDays =Math.floor((diff/days)-diffYears*365); var diffHours =Math.floor((diff-(diffYears*365+diffDays)*days)/hours); var diffMinutes =Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes); var diffSeconds =Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds); document.getElementById("sitetime").innerHTML=" 已运行"+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒"; } </script> <script> //入口 function init() { var wd= _GET("wd"); var url= _GET("url"); if(wd==="" && url==="" ){ //w="...请输入视频地址... "; w='<br><br><font size="4" color="<?php echo $skin["color"] ?>">...视</font><font color="<?php echo $skin["color"] ?>">频地址不能为空...</font>'; $(".date").html(w); } if(wd!==""){getvideo(wd);} w="<?php echo $CONFIG["play"]["all"]["by"]; ?>"; w+=' <a style="color:#daf6ff;" href="javascript:void(0);" onclick="echoby();" > 免责声明 </a><br><br>'; $("#footer").html(w); toggleCenter(); } //显示版权 function echoby() { alert("本站所有视频均来自外部引用,本站不存储不制作任何视频!\r\n 如有侵权问题,请与源站联系,谢谢合作!"); } //搜索排行 function echotop(){ if ($("#main").html().indexOf("搜索排行榜")!=-1){ $("#main").html(""); }else{ var w = "<br><br><div style='text-align:center;'><h3>搜索排行榜-TOP100</h3>"; <?php arsort($TOPDATA);$i=0; foreach ($TOPDATA as $key=>$val ): ?> title="<?php echo $key; ?>"; w+= "<a target='_parent' class='list_btn' href='./so.php?wd=<?php echo rawurlencode($key); ?>' title='人气:<?php echo $val; ?>℃'><strong>" + title+ "</strong></a>"; <?php $i++; if($i==100){break;}?> <?php endforeach; ?> w+= "</div>"; $("#main").html(w); } toggleCenter(); } //刷新列表 function relist(data){ if(data&&data.success) { var v=data.info; var w = "<br><br><div style='text-align:center;'><h3>搜索到相关视频" + v.length + "个,请点击访问</h3>"; for (i = 0, len = v.length; i < len; i++) { /* _blank:新窗口打开。 _parent:在父窗口中打开链接。 _self:默认,当前页面跳转。 _top:在当前窗体打开链接,并替换当前的整个窗体(框架页)。 */ var href="./?index"+v[i].id +"-" + v[i].flag+"-1.htm"; var title=removeHTMLTag(v[i].title,true)+"(" +(v[i].from)+")"; w+= "<a class='list_btn ' target='_self' href='" +href +"' title='"+ title+"' ><strong>" + title + "</strong></a>"; } w+= "</div>"; }else{ var w='<h3 >很抱歉,未搜索到相关资源</h3>'; $("#info").html('请修改影片名后重新搜索'); } $("#main").html(w); $("#body").show(); toggleCenter(); } //取视频数据 function getvideo(word){ $.ajax({ url: './<?php echo $CONFIG["API_PATH"]; ?>?out=jsonp&wd='+word, timeout:30000, dataType: 'jsonp', jsonp: 'cb', beforeSend: function() { $("#body").hide(); $("#main").html('<h3 >正在搜索中,请稍后...</h3>'); }, success: function (data) { relist(data); }, error: function () { relist(); } }); } //自适应大小位置 function toggleCenter() { if($("#main").height() + $("#clock").height()>$(window).height()){ $("#clock").css("position","static"); }else{ $("#clock").css("position","absolute");$("#clock").css("top",($(window).height() -$("#clock").height())/2-20); } if($(window).width()<=$("#clock").width()){$("#clock").css("left",0);}else{ $("#clock").css("left",($(window).width()-$("#clock").width())/2);} } $(window).resize(function(){ toggleCenter();}); init(); </script> </body> </html>美化搜索结果页面
最新发布
06-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值