国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > JS > 正文

JS實現(xiàn)的適合做faq或menu滑動效果示例

2024-05-06 16:32:54
字體:
供稿:網(wǎng)友

本文實例講述了JS實現(xiàn)的適合做faq或menu滑動效果。分享給大家供大家參考,具體如下:

<!CTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt--><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css"><!--body,div,ul,li,p,h1,h2{ margin:0; padding:0; border:0; background:#FAFAFA; font-family:Arial, Helvetica, sans-serif,"宋體"}body{ text-align:center; font-size:12px}li{ list-style:none}.rolinList{ width:402px; height:auto; margin:20px auto 0 auto; text-align:left}.rolinList li{margin-bottom:1px;border:1px solid #DADADA}.rolinList li h2{ width:380px; height:40px; background:#fff; font-size:14px; line-height:40px; padding-left:20px; color:#333; cursor:pointer}.content{ height:150px;width:400px; background:#fff; background:#FAFAFA}.content p{ margin:12px}--></style><script type="text/javascript">//<![CDATA[window.onload = function() {rolinTab("rolin")}function rolinTab(obj) {var list = $(obj).getElementsByTagName("LI");var state = {show:false,hidden:false,showObj:false};for (var i=0; i<list.length; i++) {var tmp = new rolinItem(list[i],state);if (i == 0) tmp.pShow();}}function rolinItem(obj,state) {var speed = 0.0666; var range = 1;var interval;var tarH;var tar = this;var head = getFirstChild(obj);var content = getNextChild(head);var isOpen = false;this.pHidden = function() {if (isOpen) hidden();}this.pShow = show;var baseH = content.offsetHeight;content.style.display = "none";var isOpen = false;head.onmouseover = function() {this.style.background = "#EFEFEF";}head.onmouseout = mouseout;head.onclick = function() {this.style.background = "#EFEFEF";if (!state.show && !state.hidden) {if (!isOpen) {head.onmouseout = null;show();} else {hidden();}}}function mouseout() {this.style.background = "#FFF"}function show() {head.style.borderBottom = "1px solid #DADADA";state.show = true;if (state.openObj && state.openObj != tar ) {state.openObj.pHidden();}content.style.height = "0px";content.style.display = "block";content.style.overflow = "hidden";state.openObj = tar;tarH = baseH;interval = setInterval(move,10);}function showS() {isOpen = true;state.show = false;}function hidden() {state.hidden = true;tarH = 0;interval = setInterval(move,10);}function hiddenS() {head.style.borderBottom = "none";head.onmouseout = mouseout;head.onmouseout();content.style.display = "none";isOpen = false;state.hidden = false;}function move() {var dist = (tarH - content.style.height.pxToNum())*speed;if (Math.abs(dist) < 1) dist = dist > 0 ? 1: -1;content.style.height = (content.style.height.pxToNum() + dist) + "px";if (Math.abs(content.style.height.pxToNum() - tarH) <= range ) {clearInterval(interval);content.style.height = tarH + "px";if (tarH != 0) {showS()} else {hiddenS();}}}}var $ = function($) {return document.getElementById($)};String.prototype.pxToNum = function() {return Number(this.replace("px",""))}function getFirstChild(obj) {var result = obj.firstChild;while (!result.tagName) {result = result.nextSibling;}return result;}function getNextChild(obj) {var result = obj.nextSibling;while (!result.tagName) {result = result.nextSibling;}return result;}//]]></script><ul id="rolin">  <li>  <h2>VeVb武林網(wǎng) 1</h2>  <div <p>VeVb武林網(wǎng)--專業(yè)IT綜合性網(wǎng)站<br /><br /><a target="_blank" href="http://m.survivalescaperooms.com/">http://m.survivalescaperooms.com/</a></p>  </div>  </li>  <li>  <h2>VeVb武林網(wǎng) 2</h2>  <div <p>VeVb武林網(wǎng)--專業(yè)IT綜合性網(wǎng)站<br /><br /><a target="_blank" href="http://m.survivalescaperooms.com/">http://m.survivalescaperooms.com/</a></p>  </div>  </li>  <li>  <h2>VeVb武林網(wǎng) 3</h2>  <div <p>VeVb武林網(wǎng)--專業(yè)IT綜合性網(wǎng)站<br /><br /><a target="_blank" href="http://m.survivalescaperooms.com/">http://m.survivalescaperooms.com/</a></p>  </div>  </li>  <li>  <h2>VeVb武林網(wǎng) 4</h2>  <div <p>VeVb武林網(wǎng)--專業(yè)IT綜合性網(wǎng)站<br /><br /><a target="_blank" href="http://m.survivalescaperooms.com/">http://m.survivalescaperooms.com/</a></p>  </div>  </li>  <li>  <h2>VeVb武林網(wǎng) 5</h2>  <div <p>VeVb武林網(wǎng)--專業(yè)IT綜合性網(wǎng)站<br /><br /><a target="_blank" href="http://m.survivalescaperooms.com/">http://m.survivalescaperooms.com/</a></p>  </div>  </li>  <li>  <h2>VeVb武林網(wǎng) 6</h2>  <div <p>VeVb武林網(wǎng)--專業(yè)IT綜合性網(wǎng)站<br /><br /><a target="_blank" href="http://m.survivalescaperooms.com/">http://m.survivalescaperooms.com/</a></p>  </div>  </li></ul>

希望本文所述對大家JavaScript程序設(shè)計有所幫助。


注:相關(guān)教程知識閱讀請移步到JavaScript/Ajax教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 岱山县| 铜梁县| 张家港市| 越西县| 石屏县| 青海省| 辽宁省| 昌宁县| 惠来县| 石柱| 普宁市| 车致| 慈溪市| 灵武市| 岐山县| 常州市| 大洼县| 依安县| 米泉市| 柳州市| 永顺县| 辉南县| 涟源市| 亚东县| 南漳县| 科技| 辉南县| 望奎县| 托克托县| 易门县| 芒康县| 临湘市| 平塘县| 英德市| 东台市| 抚宁县| 五台县| 大石桥市| 庆城县| 都兰县| 兰坪|