搜尋
首頁web前端html教學《Java Script DOM编程艺术》读书笔记--DOM_html/css_WEB-ITnose

1、文档:DOM中的“D”

"D"代表document(文档)

2、对象:DOM中的“O”

“O”代表object(对象) 对象的分类

  • 用户定义对象(user-defined object)
  • 内建对象(native object)
  • 宿主对象(host object)

window对象window对象对应着浏览器窗口本身,这个对象的属性和方法通常统称为BOM(浏览器对象模型)BOM提供了window.open和window.blur等方法。以至于被滥用于各种弹出窗口和下拉菜单

3、模型:DOM中的“M”

“M”代表“Model”(模型)DOM把一份文档表示为一棵树(数学意义上的概念)示例代码

<!DOCTYPE html><html lang="en">  <head>    <meta charset="utf-8" />    <title>Shoping List<title>  </head>  <body>     <h1 id="What-to-buy">What to buy</h1>     <p title="a gentle reminder">Don’t forget to buy this stuff.<p>     <ul id="purchases">        <li> A tin of beans<li>        <li class="sale">Cheese<li>        <li class="sale important">Milk<li>        </ul>    <body>  </html>代码中<html>相当于树根,即根元素。<head>和<body>属于下一个分支,位于同一层次且互不包含,属于兄弟关系。<head>元素有两个子元素<meta>和<title>(属于兄弟关系)<body>元素有三个子元素<p>、<h1 id="ul-这三个属于兄弟关系-ul-也是一个父元素-有三个子元素-他们都是-li-元素-pre-p-如果你能把一个文档的各种元素想象成一棵家谱树-我们就可以用同样的术语描述DOM-但我觉得称为-strong-节点树-strong-更准确-p-h-节点">、<ul>(这三个属于兄弟关系。<ul>也是一个父元素,有三个子元素,他们都是<li>元素。

如果你能把一个文档的各种元素想象成一棵家谱树,我们就可以用同样的术语描述DOM。但我觉得称为“节点树”更准确

4、节点

节点(node)属于网络术语,它表示网络中的一个连接点。一个网络就是由一些节点构成的集合。DOM也是同样的情况,文档是由节点构成的集合。

  • 元素节点
  • 文本节点
  • 属性节点

4、1元素节点

DOM的原子是元素节点(element node)诸如

之类的元素。标签的名字就是元素的名字。元素也可以包含其他的元素。没有被包含在其他元素的唯一元素是元素,它是我们的节点树的根元素。

4、2文本节点

在上述例子中,

元素包含着文本“don't forget to buy this stuff.”它就是一个文本节点(text node)。

4、3属性节点

属性节点是对元素做出更具体的描述。例如,几乎所有的元素都有一个title属性,我们可以利用这个属性对包含在元素里的东西做出准确的描述:

<p title="a gentle reminder">Don't forget to buy this stuff.<p>

在DOM中title="a gentle reminder"是一个属性节点(attribute node),在前面的例子中无序清单元素

    有个id属性。有些清单元素
  • 有class属性。

    三者之间的关系.png

    4、4 CSS

    类似javascript脚本,我们也可以将CSS样式嵌在文档

    部分(style>标签之间)。也可以放在另外的一个文件里。**在HTML文件中引用CSS文件的格式:
    <link type="text/css" href="file.css" rel="stylesheet">

    继承(inheritance)是CSS技术中的一项强大功能。1)、 class属性

    <p class="special">This pargraph has the special class<p><h2 id="So-dose-this-headline">So dose this headline</h2>

    在样式表里可以为上面的代码进行定义

    special{font-style: italic;}

    还可以这样定义

    h2.special{text-transform: uppercase;}

    2)、id属性id属性的用途是给网页里的某个元素加上一个独一无二的标识符:

    <ul id="purchases">

    样式表定义

    #purchases{border:1px solid white;background-color:#333;color:#ccc;padding:1em;}
    #purchases li{font-weight:bold;}

    4、5获取元素

    有3种DOM方法可获取元素节点,分别是通过元素ID、通过标签名和通过类名字来获取

    • getElementById
    • getElementsByTagName
    • getElementsByClassName

    1)getElementById

    此方法将返回一个与那个有着给定id属性值的元素节点对应的对象,在javascript里注意大小写。它是document对象特有的函数,在脚本代码里,函数名的后面必须跟有一对圆括号,这对圆括号包含这函数的参数。document.getElementById(id)在getElementById方法中只有一个参数:你想获得的那个元素的id属性的值,这个id属性必须放在单引号或双引号里。docment.getElementById("purchases")这个调用将返回一个对象,这个对象对应着document对象里的一个独一无二的元素,那个元素的HTLM id属性值是purchases

              Shoping List<title>  </head>  <body>     <h1 id="What-to-buy">What to buy</h1>     <p title="a gentle reminder">Don’t forget to buy this stuff.<p>     <ul id="purchases">        <li> A tin of beans<li>        <li class="sale">Cheese<li>        <li class="sale important">Milk<li>        </ul>     <script>         alert(typeof docment.getElementById("purchases"));     </script>    <body>  </html>//利用`typeof`操作符进行验证(typeof操作符可以告诉我们它的操作数是一个字母、数值、函数、布尔值还是对象。</pre>   <p>验证可得是一个对象</p>   <h3 id="getElementsByTagName">2)getElementsByTagName</h3>   <p>getElementsByTagName方法返回一个对象数组,每个对象分别对应着文档里有着给定标签的一个元素。它的参数是标签的名字:decument.getElementByTagName(tag)</p>   <pre class='brush:php;toolbar:false;'>alert(document.getElementsByTagName("li").length);//显示文档里的列表元素个数为:3</pre>   <pre class='brush:php;toolbar:false;'><!DOCTYPE html><html lang="en">  <head>    <meta charset="utf-8" />    <title>Shoping List<title>  </head>  <body>     <h1 id="What-to-buy">What to buy</h1>     <p title="a gentle reminder">Don’t forget to buy this stuff.<p>     <ul id="purchases">        <li> A tin of beans<li>        <li class="sale">Cheese<li>        <li class="sale important">Milk<li>        </ul>     <script>         var items=document.getElementByTagName("li");         for (var i=0; i<items.length;i++){         alert(typeof items[i]);         }     </script>    <body>  </html>//代码运行结果显示三个alert对话框,显示的消息都是“object”。</pre>   <p>getElementsByTagName允许把一个通配符作为它的参数,通配符(*)必须放在引号里</p>   <pre class='brush:php;toolbar:false;'>alert(document.getElementsByTagName("*").length);//可以知道文档里有多少个元素节点</pre>   <pre class='brush:php;toolbar:false;'>var shopping=document.getElementById("purchases");var items=shopping.getElementsByTagName("*");//程序运行结果,items数组将只包含id属性值是purshase的元素清单的元素</pre>   <h3 id="getElementByClassName">3)getElementByClassName</h3>   <p>这个方法让我们能够通过class属性中的类名来访问元素,getElementByClassName也只接受一个参数,就是类名:</p>   <pre class='brush:php;toolbar:false;'>getElementByClassName(class)</pre>   <p>这个方法的返回值也与getElementsByTagName类似,都是一个具有相同类名的元素的数组。</p>   <pre class='brush:php;toolbar:false;'>document.getElementsByClassName("sale")</pre>   <p>利用这种方法还可有查找那些带有多个类名的元素。多个类名之间用空格分开即可</p>   <pre class='brush:php;toolbar:false;'>alert(document.getElementsByClassName("important sale").length);//对话框显示1,表示只有一个元素匹配。类名的顺序不重要,就算元素还带有更多类名也没有关系。</pre>   <p>也可以和getElementById组合使用</p>   <pre class='brush:php;toolbar:false;'>     var shopping=document.getElementById("purchase");     var sales=shopping.getElementsByClassName("sale");sales数组中包含的就只是位于“purchases”列表中的带有“sale”类的元素。</pre>   <p>getElementByClassName方法非常有用,但只有较新的浏览器才支持它。所以,需要使用已有的DOM方法来实现自己的getElementsByClassName。</p>   <pre class='brush:php;toolbar:false;'>function getElementsByClassName(node,classname){if (node.getElementsByClassName){//使用现有的方法return node.getElementsByTagName("*");for (var i=0; i<elems.length;i++){  if(elems[i].ClassName.indexof(classname)!= -1){results[results.length]=elems[i];          }      }return results;    }}</pre>   <h4 id="获取和设置属性">5 获取和设置属性</h4>   <ul>       <li>
    <strong>getAttribute方法</strong>(获取元素的属性)</li>    <li>
    <strong>setAttribute方法</strong>(更改属性节点值)5、1getAttributegetAttribute是一个函数,它只有一个参数(你所要查询的属性的名称)</li>   </ul>   </li>
    </ul></div><div class="wzconShengming_sp"><div class="bzsmdiv_sp">陳述</div><div>本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn</div></div></div><div class="phpgenera_Details_mainL4"><div class="phpmain1_2_top"><a href="javascript:void(0);" class="phpmain1_2_top_title">相關文章<img class="lazy"
                                data-src="/static/imghwm/index2_title2.png" src="/static/imghw/default1.png" alt="" /></a></div><div class="phpgenera_Details_mainL4_info"><div class="phphistorical_Version2_mids"><a href="https://m.php.cn/zh-tw/faq/1796794693.html" title="了解HTML,CSS和JavaScript:初學者指南" class="phphistorical_Version2_mids_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                data-src="https://img.php.cn/upload/article/001/253/068/174438733162787.jpg?x-oss-process=image/resize,p_40" alt="了解HTML,CSS和JavaScript:初學者指南" src="/static/imghw/default1.png"  /></a><a href="https://m.php.cn/zh-tw/faq/1796794693.html" title="了解HTML,CSS和JavaScript:初學者指南" class="phphistorical_Version2_mids_title">了解HTML,CSS和JavaScript:初學者指南</a><span class="Articlelist_txts_time">Apr 12, 2025 am	 12:02 AM</span><p class="Articlelist_txts_p">WebDevelovermentReliesonHtml,CSS和JavaScript:1)HTMLStructuresContent,2)CSSStyleSIT和3)JavaScriptAddSstractivity,形成thebasisofmodernWebemodernWebExexperiences。</p></div><div class="phphistorical_Version2_mids"><a href="https://m.php.cn/zh-tw/faq/1796794180.html" title="HTML的角色:構建Web內容" class="phphistorical_Version2_mids_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                data-src="https://img.php.cn/upload/article/001/253/068/174430155217186.jpg?x-oss-process=image/resize,p_40" alt="HTML的角色:構建Web內容" src="/static/imghw/default1.png"  /></a><a href="https://m.php.cn/zh-tw/faq/1796794180.html" title="HTML的角色:構建Web內容" class="phphistorical_Version2_mids_title">HTML的角色:構建Web內容</a><span class="Articlelist_txts_time">Apr 11, 2025 am	 12:12 AM</span><p class="Articlelist_txts_p">HTML的作用是通過標籤和屬性定義網頁的結構和內容。 1.HTML通過到、等標籤組織內容,使其易於閱讀和理解。 2.使用語義化標籤如、等增強可訪問性和SEO。 3.優化HTML代碼可以提高網頁加載速度和用戶體驗。</p></div><div class="phphistorical_Version2_mids"><a href="https://m.php.cn/zh-tw/faq/1796793634.html" title="HTML和代碼:仔細觀察術語" class="phphistorical_Version2_mids_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                data-src="https://img.php.cn/upload/article/001/253/068/174424853215422.jpg?x-oss-process=image/resize,p_40" alt="HTML和代碼:仔細觀察術語" src="/static/imghw/default1.png"  /></a><a href="https://m.php.cn/zh-tw/faq/1796793634.html" title="HTML和代碼:仔細觀察術語" class="phphistorical_Version2_mids_title">HTML和代碼:仔細觀察術語</a><span class="Articlelist_txts_time">Apr 10, 2025 am	 09:28 AM</span><p class="Articlelist_txts_p">htmlisaspecifictypefodyfocusedonstructuringwebcontent,而“代碼” badlyLyCludEslanguagesLikeLikejavascriptandPytyPythonForFunctionality.1)htmldefineswebpagertuctureduseTags.2)“代碼”代碼“ code” code code code codeSpassSesseseseseseseseAwiderRangeLangeLangeforLageforLogageforLogicIctInterract</p></div><div class="phphistorical_Version2_mids"><a href="https://m.php.cn/zh-tw/faq/1796793129.html" title="HTML,CSS和JavaScript:Web開發人員的基本工具" class="phphistorical_Version2_mids_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                data-src="https://img.php.cn/upload/article/001/253/068/174412873346901.jpg?x-oss-process=image/resize,p_40" alt="HTML,CSS和JavaScript:Web開發人員的基本工具" src="/static/imghw/default1.png"  /></a><a href="https://m.php.cn/zh-tw/faq/1796793129.html" title="HTML,CSS和JavaScript:Web開發人員的基本工具" class="phphistorical_Version2_mids_title">HTML,CSS和JavaScript:Web開發人員的基本工具</a><span class="Articlelist_txts_time">Apr 09, 2025 am	 12:12 AM</span><p class="Articlelist_txts_p">HTML、CSS和JavaScript是Web開發的三大支柱。 1.HTML定義網頁結構,使用標籤如、等。 2.CSS控製網頁樣式,使用選擇器和屬性如color、font-size等。 3.JavaScript實現動態效果和交互,通過事件監聽和DOM操作。</p></div><div class="phphistorical_Version2_mids"><a href="https://m.php.cn/zh-tw/faq/1796792987.html" title="HTML,CSS和JavaScript的角色:核心職責" class="phphistorical_Version2_mids_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                data-src="https://img.php.cn/upload/article/001/253/068/174411031220217.jpg?x-oss-process=image/resize,p_40" alt="HTML,CSS和JavaScript的角色:核心職責" src="/static/imghw/default1.png"  /></a><a href="https://m.php.cn/zh-tw/faq/1796792987.html" title="HTML,CSS和JavaScript的角色:核心職責" class="phphistorical_Version2_mids_title">HTML,CSS和JavaScript的角色:核心職責</a><span class="Articlelist_txts_time">Apr 08, 2025 pm	 07:05 PM</span><p class="Articlelist_txts_p">HTML定義網頁結構,CSS負責樣式和佈局,JavaScript賦予動態交互。三者在網頁開發中各司其職,共同構建豐富多彩的網站。</p></div><div class="phphistorical_Version2_mids"><a href="https://m.php.cn/zh-tw/faq/1796791823.html" title="HTML容易為初學者學習嗎?" class="phphistorical_Version2_mids_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                data-src="https://img.php.cn/upload/article/001/253/068/174395586298618.jpg?x-oss-process=image/resize,p_40" alt="HTML容易為初學者學習嗎?" src="/static/imghw/default1.png"  /></a><a href="https://m.php.cn/zh-tw/faq/1796791823.html" title="HTML容易為初學者學習嗎?" class="phphistorical_Version2_mids_title">HTML容易為初學者學習嗎?</a><span class="Articlelist_txts_time">Apr 07, 2025 am	 12:11 AM</span><p class="Articlelist_txts_p">HTML適合初學者學習,因為它簡單易學且能快速看到成果。 1)HTML的學習曲線平緩,易於上手。 2)只需掌握基本標籤即可開始創建網頁。 3)靈活性高,可與CSS和JavaScript結合使用。 4)豐富的學習資源和現代工具支持學習過程。</p></div><div class="phphistorical_Version2_mids"><a href="https://m.php.cn/zh-tw/faq/1796791144.html" title="HTML中起始標籤的示例是什麼?" class="phphistorical_Version2_mids_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                data-src="https://img.php.cn/upload/article/001/253/068/174386905283883.jpg?x-oss-process=image/resize,p_40" alt="HTML中起始標籤的示例是什麼?" src="/static/imghw/default1.png"  /></a><a href="https://m.php.cn/zh-tw/faq/1796791144.html" title="HTML中起始標籤的示例是什麼?" class="phphistorical_Version2_mids_title">HTML中起始標籤的示例是什麼?</a><span class="Articlelist_txts_time">Apr 06, 2025 am	 12:04 AM</span><p class="Articlelist_txts_p">AnexampleOfAstartingTaginHtmlis,beginSaparagraph.startingTagSareEssentialInhtmlastheyInitiateEllements,defiteTheeTheErtypes,andarecrucialforsstructuringwebpages wepages webpages andConstructingthedom。</p></div><div class="phphistorical_Version2_mids"><a href="https://m.php.cn/zh-tw/faq/1796790923.html" title="如何利用CSS的Flexbox佈局實現菜單中虛線分割效果的居中對齊?" class="phphistorical_Version2_mids_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                data-src="https://img.php.cn/upload/article/001/246/273/174286321766559.jpg?x-oss-process=image/resize,p_40" alt="如何利用CSS的Flexbox佈局實現菜單中虛線分割效果的居中對齊?" src="/static/imghw/default1.png"  /></a><a href="https://m.php.cn/zh-tw/faq/1796790923.html" title="如何利用CSS的Flexbox佈局實現菜單中虛線分割效果的居中對齊?" class="phphistorical_Version2_mids_title">如何利用CSS的Flexbox佈局實現菜單中虛線分割效果的居中對齊?</a><span class="Articlelist_txts_time">Apr 05, 2025 pm	 01:24 PM</span><p class="Articlelist_txts_p">如何設計菜單中的虛線分割效果?在設計菜單時,菜名和價格的左右對齊通常不難實現,但中間的虛線或點如何...</p></div></div><a href="https://m.php.cn/zh-tw/web-designer.html" class="phpgenera_Details_mainL4_botton"><span>See all articles</span><img class="lazy" data-src="/static/imghwm/down_right.png" src="/static/imghw/default1.png" alt="" /></a></div><ins class="adsbygoogle"
         style="display:block"
         data-ad-format="fluid"
         data-ad-layout-key="-6t+ed+2i-1n-4w"
         data-ad-client="ca-pub-5902227090019525"
         data-ad-slot="8966999616"></ins><script>     (adsbygoogle = window.adsbygoogle || []).push({});
    </script><div class="AI_ToolDetails_main4sR"><div class="phpgenera_Details_mainR3"><div class="phpmain1_4R_readrank"><div class="phpmain1_4R_readrank_top"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'"
                                onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                data-src="/static/imghwm/hottools2.png" src="/static/imghw/default1.png" alt="" /><h2>熱AI工具</h2></div><div class="phpgenera_Details_mainR3_bottom"><div class="phpmain_tab2_mids_top"><a href="https://m.php.cn/zh-tw/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_top_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'"
                                        onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                        data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411540686492.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undresser.AI Undress" /></a><div class="phpmain_tab2_mids_info"><a href="https://m.php.cn/zh-tw/ai/undresserai-undress" title="Undresser.AI Undress"class="phpmain_tab2_mids_title"><h3>Undresser.AI Undress</h3></a><p>人工智慧驅動的應用程序,用於創建逼真的裸體照片</p></div></div><div class="phpmain_tab2_mids_top"><a href="https://m.php.cn/zh-tw/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_top_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'"
                                        onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                        data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411552797167.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="AI Clothes Remover" /></a><div class="phpmain_tab2_mids_info"><a href="https://m.php.cn/zh-tw/ai/ai-clothes-remover" title="AI Clothes Remover"class="phpmain_tab2_mids_title"><h3>AI Clothes Remover</h3></a><p>用於從照片中去除衣服的線上人工智慧工具。</p></div></div><div class="phpmain_tab2_mids_top"><a href="https://m.php.cn/zh-tw/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_top_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'"
                                        onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                        data-src="https://img.php.cn/upload/ai_manual/001/246/273/173410641626608.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undress AI Tool" /></a><div class="phpmain_tab2_mids_info"><a href="https://m.php.cn/zh-tw/ai/undress-ai-tool" title="Undress AI Tool"class="phpmain_tab2_mids_title"><h3>Undress AI Tool</h3></a><p>免費脫衣圖片</p></div></div><div class="phpmain_tab2_mids_top"><a href="https://m.php.cn/zh-tw/ai/clothoffio" title="Clothoff.io" class="phpmain_tab2_mids_top_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'"
                                        onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                        data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411529149311.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Clothoff.io" /></a><div class="phpmain_tab2_mids_info"><a href="https://m.php.cn/zh-tw/ai/clothoffio" title="Clothoff.io"class="phpmain_tab2_mids_title"><h3>Clothoff.io</h3></a><p>AI脫衣器</p></div></div><div class="phpmain_tab2_mids_top"><a href="https://m.php.cn/zh-tw/ai/ai-hentai-generator" title="AI Hentai Generator" class="phpmain_tab2_mids_top_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'"
                                        onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                        data-src="https://img.php.cn/upload/ai_manual/001/246/273/173405034393877.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="AI Hentai Generator" /></a><div class="phpmain_tab2_mids_info"><a href="https://m.php.cn/zh-tw/ai/ai-hentai-generator" title="AI Hentai Generator"class="phpmain_tab2_mids_title"><h3>AI Hentai Generator</h3></a><p>免費產生 AI 無盡。</p></div></div></div><div class="phpgenera_Details_mainR3_more"><a href="https://m.php.cn/zh-tw/ai">顯示更多</a></div></div></div><div class="phpgenera_Details_mainR4"><div class="phpmain1_4R_readrank"><div class="phpmain1_4R_readrank_top"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'"
                                onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                data-src="/static/imghwm/hotarticle2.png" src="/static/imghw/default1.png" alt="" /><h2>熱門文章</h2></div><div class="phpgenera_Details_mainR4_bottom"><div class="phpgenera_Details_mainR4_bottoms"><a href="https://m.php.cn/zh-tw/faq/1796780570.html" title="R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)</a><div class="phpgenera_Details_mainR4_bottoms_info"><span>3 週前</span><span>By尊渡假赌尊渡假赌尊渡假赌</span></div></div><div class="phpgenera_Details_mainR4_bottoms"><a href="https://m.php.cn/zh-tw/faq/1796780641.html" title="R.E.P.O.最佳圖形設置" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O.最佳圖形設置</a><div class="phpgenera_Details_mainR4_bottoms_info"><span>3 週前</span><span>By尊渡假赌尊渡假赌尊渡假赌</span></div></div><div class="phpgenera_Details_mainR4_bottoms"><a href="https://m.php.cn/zh-tw/faq/1796785841.html" title="刺客信條陰影:貝殼謎語解決方案" class="phpgenera_Details_mainR4_bottom_title">刺客信條陰影:貝殼謎語解決方案</a><div class="phpgenera_Details_mainR4_bottoms_info"><span>2 週前</span><span>ByDDD</span></div></div><div class="phpgenera_Details_mainR4_bottoms"><a href="https://m.php.cn/zh-tw/faq/1796780520.html" title="R.E.P.O.如果您聽不到任何人,如何修復音頻" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O.如果您聽不到任何人,如何修復音頻</a><div class="phpgenera_Details_mainR4_bottoms_info"><span>3 週前</span><span>By尊渡假赌尊渡假赌尊渡假赌</span></div></div><div class="phpgenera_Details_mainR4_bottoms"><a href="https://m.php.cn/zh-tw/faq/1796779766.html" title="WWE 2K25:如何解鎖Myrise中的所有內容" class="phpgenera_Details_mainR4_bottom_title">WWE 2K25:如何解鎖Myrise中的所有內容</a><div class="phpgenera_Details_mainR4_bottoms_info"><span>4 週前</span><span>By尊渡假赌尊渡假赌尊渡假赌</span></div></div></div><div class="phpgenera_Details_mainR3_more"><a href="https://m.php.cn/zh-tw/article.html">顯示更多</a></div></div></div><div class="phpgenera_Details_mainR3"><div class="phpmain1_4R_readrank"><div class="phpmain1_4R_readrank_top"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'"
                                onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                data-src="/static/imghwm/hottools2.png" src="/static/imghw/default1.png" alt="" /><h2>熱工具</h2></div><div class="phpgenera_Details_mainR3_bottom"><div class="phpmain_tab2_mids_top"><a href="https://m.php.cn/zh-tw/toolset/development-tools/660" title="Atom編輯器mac版下載" class="phpmain_tab2_mids_top_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'"
                                            onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                            data-src="https://img.php.cn/upload/manual/000/000/001/58ed8cfa94c1a582.jpg" src="/static/imghw/default1.png" alt="Atom編輯器mac版下載" /></a><div class="phpmain_tab2_mids_info"><a href="https://m.php.cn/zh-tw/toolset/development-tools/660" title="Atom編輯器mac版下載" class="phpmain_tab2_mids_title"><h3>Atom編輯器mac版下載</h3></a><p>最受歡迎的的開源編輯器</p></div></div><div class="phpmain_tab2_mids_top"><a href="https://m.php.cn/zh-tw/toolset/development-tools/502" title="ZendStudio 13.5.1 Mac" class="phpmain_tab2_mids_top_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'"
                                            onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                            data-src="https://img.php.cn/upload/manual/000/000/001/58d3631514435840.png" src="/static/imghw/default1.png" alt="ZendStudio 13.5.1 Mac" /></a><div class="phpmain_tab2_mids_info"><a href="https://m.php.cn/zh-tw/toolset/development-tools/502" title="ZendStudio 13.5.1 Mac" class="phpmain_tab2_mids_title"><h3>ZendStudio 13.5.1 Mac</h3></a><p>強大的PHP整合開發環境</p></div></div><div class="phpmain_tab2_mids_top"><a href="https://m.php.cn/zh-tw/toolset/development-tools/1575" title="DVWA" class="phpmain_tab2_mids_top_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'"
                                            onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                            data-src="https://img.php.cn/upload/manual/000/000/005/169233952150073.png" src="/static/imghw/default1.png" alt="DVWA" /></a><div class="phpmain_tab2_mids_info"><a href="https://m.php.cn/zh-tw/toolset/development-tools/1575" title="DVWA" class="phpmain_tab2_mids_title"><h3>DVWA</h3></a><p>Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中</p></div></div><div class="phpmain_tab2_mids_top"><a href="https://m.php.cn/zh-tw/toolset/development-tools/506" title="WebStorm Mac版" class="phpmain_tab2_mids_top_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'"
                                            onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                            data-src="https://img.php.cn/upload/manual/000/000/001/58d36e6254963493.png" src="/static/imghw/default1.png" alt="WebStorm Mac版" /></a><div class="phpmain_tab2_mids_info"><a href="https://m.php.cn/zh-tw/toolset/development-tools/506" title="WebStorm Mac版" class="phpmain_tab2_mids_title"><h3>WebStorm Mac版</h3></a><p>好用的JavaScript開發工具</p></div></div><div class="phpmain_tab2_mids_top"><a href="https://m.php.cn/zh-tw/toolset/development-tools/1574" title="Safe Exam Browser" class="phpmain_tab2_mids_top_img"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'"
                                            onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                            data-src="https://img.php.cn/upload/manual/000/000/017/169233952169011.png" src="/static/imghw/default1.png" alt="Safe Exam Browser" /></a><div class="phpmain_tab2_mids_info"><a href="https://m.php.cn/zh-tw/toolset/development-tools/1574" title="Safe Exam Browser" class="phpmain_tab2_mids_title"><h3>Safe Exam Browser</h3></a><p>Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。</p></div></div></div><div class="phpgenera_Details_mainR3_more"><a href="https://m.php.cn/zh-tw/ai">顯示更多</a></div></div></div><div class="phpgenera_Details_mainR4"><div class="phpmain1_4R_readrank"><div class="phpmain1_4R_readrank_top"><img onerror="this.onerror=''; this.src='/static/imghwm/default1.png'"
                                onerror="this.onerror=''; this.src='/static/imghwm/default1.png'" class="lazy"
                                data-src="/static/imghwm/hotarticle2.png" src="/static/imghw/default1.png" alt="" /><h2>熱門話題</h2></div><div class="phpgenera_Details_mainR4_bottom"><div class="phpgenera_Details_mainR4_bottoms"><a href="https://m.php.cn/zh-tw/faq/gmailyxdlrkzn" title="gmail信箱登陸入口在哪裡"  class="phpgenera_Details_mainR4_bottom_title">gmail信箱登陸入口在哪裡</a><div class="phpgenera_Details_mainR4_bottoms_info"><div class="phpgenera_Details_mainR4_bottoms_infos"><img class="lazy" data-src="/static/imghwm/eyess.png" src="/static/imghw/default1.png"
                                            alt="" /><span>7469</span></div><div class="phpgenera_Details_mainR4_bottoms_infos"><img class="lazy" data-src="/static/imghwm/tiezi.png" src="/static/imghw/default1.png"
                                            alt="" /><span>15</span></div></div></div><div class="phpgenera_Details_mainR4_bottoms"><a href="https://m.php.cn/zh-tw/faq/cakephp-tutor" title="CakePHP 教程"  class="phpgenera_Details_mainR4_bottom_title">CakePHP 教程</a><div class="phpgenera_Details_mainR4_bottoms_info"><div class="phpgenera_Details_mainR4_bottoms_infos"><img class="lazy" data-src="/static/imghwm/eyess.png" src="/static/imghw/default1.png"
                                            alt="" /><span>1376</span></div><div class="phpgenera_Details_mainR4_bottoms_infos"><img class="lazy" data-src="/static/imghwm/tiezi.png" src="/static/imghw/default1.png"
                                            alt="" /><span>52</span></div></div></div><div class="phpgenera_Details_mainR4_bottoms"><a href="https://m.php.cn/zh-tw/faq/steamdzhmcssmgs" title="steam的賬戶名稱是什麼格式"  class="phpgenera_Details_mainR4_bottom_title">steam的賬戶名稱是什麼格式</a><div class="phpgenera_Details_mainR4_bottoms_info"><div class="phpgenera_Details_mainR4_bottoms_infos"><img class="lazy" data-src="/static/imghwm/eyess.png" src="/static/imghw/default1.png"
                                            alt="" /><span>77</span></div><div class="phpgenera_Details_mainR4_bottoms_infos"><img class="lazy" data-src="/static/imghwm/tiezi.png" src="/static/imghw/default1.png"
                                            alt="" /><span>11</span></div></div></div><div class="phpgenera_Details_mainR4_bottoms"><a href="https://m.php.cn/zh-tw/faq/winactivationkeyper" title="win11激活密鑰永久"  class="phpgenera_Details_mainR4_bottom_title">win11激活密鑰永久</a><div class="phpgenera_Details_mainR4_bottoms_info"><div class="phpgenera_Details_mainR4_bottoms_infos"><img class="lazy" data-src="/static/imghwm/eyess.png" src="/static/imghw/default1.png"
                                            alt="" /><span>48</span></div><div class="phpgenera_Details_mainR4_bottoms_infos"><img class="lazy" data-src="/static/imghwm/tiezi.png" src="/static/imghw/default1.png"
                                            alt="" /><span>19</span></div></div></div><div class="phpgenera_Details_mainR4_bottoms"><a href="https://m.php.cn/zh-tw/faq/newyorktimesdailybrief" title="NYT連接提示和答案"  class="phpgenera_Details_mainR4_bottom_title">NYT連接提示和答案</a><div class="phpgenera_Details_mainR4_bottoms_info"><div class="phpgenera_Details_mainR4_bottoms_infos"><img class="lazy" data-src="/static/imghwm/eyess.png" src="/static/imghw/default1.png"
                                            alt="" /><span>19</span></div><div class="phpgenera_Details_mainR4_bottoms_infos"><img class="lazy" data-src="/static/imghwm/tiezi.png" src="/static/imghw/default1.png"
                                            alt="" /><span>29</span></div></div></div></div><div class="phpgenera_Details_mainR3_more"><a href="https://m.php.cn/zh-tw/faq/zt">顯示更多</a></div></div></div></div></main><ins class="adsbygoogle"
         style="display:block"
         data-ad-format="autorelaxed"
         data-ad-client="ca-pub-5902227090019525"
         data-ad-slot="5027754603"></ins><script>     (adsbygoogle = window.adsbygoogle || []).push({});
    </script><footer><div class="footer"><div class="footertop"><img src="/static/imghwm/logo.png" alt=""><p>公益線上PHP培訓,幫助PHP學習者快速成長!</p></div><div class="footermid"><a href="https://m.php.cn/zh-tw/about/us.html">關於我們</a><a href="https://m.php.cn/zh-tw/about/disclaimer.html">免責聲明</a><a href="https://m.php.cn/zh-tw/update/article_0_1.html">Sitemap</a></div><div class="footerbottom"><p>                © php.cn All rights reserved
                </p></div></div></footer><script>isLogin = 0;</script><script type="text/javascript" src="/static/layui/layui.js"></script><script type="text/javascript" src="/static/js/global.js?4.9.47"></script><script src="https://vdse.bdstatic.com//search-video.v1.min.js"></script><link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css' type='text/css' media='all'/><script type='text/javascript' src='/static/js/viewer.min.js?1'></script><script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script><script>  var _paq = window._paq = window._paq || [];
      /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u="https://tongji.php.cn/";
        _paq.push(['setTrackerUrl', u+'matomo.php']);
        _paq.push(['setSiteId', '9']);
        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
        g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
      })();
    </script><script>        jQuery.fn.wait = function (func, times, interval) {
                var _times = times || -1, //100次
                _interval = interval || 20, //20毫秒每次
                _self = this,
                _selector = this.selector, //选择器
                _iIntervalID; //定时器id
                if( this.length ){ //如果已经获取到了,就直接执行函数
                    func && func.call(this);
                } else {
                    _iIntervalID = setInterval(function() {
                        if(!_times) { //是0就退出
                            clearInterval(_iIntervalID);
                        }
                        _times <= 0 || _times--; //如果是正数就 --
    
                        _self = $(_selector); //再次选择
                        if( _self.length ) { //判断是否取到
                            func && func.call(_self);
                            clearInterval(_iIntervalID);
                        }
                    }, _interval);
                }
                return this;
    }
    
        $("table.syntaxhighlighter").wait(function() {
            $('table.syntaxhighlighter').append("<p class='cnblogs_code_footer'><span class='cnblogs_code_footer_icon'></span></p>");
        });
        $(document).on("click", ".cnblogs_code_footer",function(){
            $(this).parents('table.syntaxhighlighter').css('display','inline-table');$(this).hide();
        });
        $('.nphpQianCont').viewer({navbar:true,title:false,toolbar:false,movable:false,viewed:function(){$('img').click(function(){$('.viewer-close').trigger('click');});}});
        </script><script>// 通用函数,用于显示或隐藏元素
    function toggleElementsDisplay(className, show) {
      const elements = document.getElementsByClassName(className);
      for (let i = 0; i < elements.length; i++) {
        elements[i].style.display = show ? "block" : "none";
      }
    }
    // 页面加载完成后执行的主函数
    document.addEventListener("DOMContentLoaded", () => {
      // 1. 绑定菜单按钮事件
      const bindMenuEvents = () => {
        const toggleDisplay = (className, show, eventId) => {
          const element = document.getElementById(eventId);
          if (element) {
            element.addEventListener("click", (event) => {
              event.preventDefault();
              toggleElementsDisplay(className, show);
            });
          }
        };
        toggleDisplay("m_editormain12main", true, "fixed_tab_img");
        toggleDisplay("m_editormain12main", false, "fixed_tab_topi");
        toggleDisplay("m_editormain12main", false, "fixed_tab_close");
        toggleDisplay("m_menu", true, "lan1sp");
        toggleDisplay("m_menu", false, "m_editormain12main_topi_sp");
        toggleDisplay("m_menu_lang", true, "lan1");
        toggleDisplay("m_menu_lang", false, "m_editormain12main_topi_lan");
      };
     // 2. 绑定滚动链接事件
    const bindScrollLinks = () => {
      const titleList = document.getElementById("fixed_tab_titlelist");
      const menuMain = document.getElementsByClassName("m_editormain12main")[0];
      const links = document.querySelectorAll('.fixed_tab_a'); 
      links.forEach(linkElement => {
        if (linkElement) {
          linkElement.addEventListener("click", async (e) => {
            e.preventDefault();
            e.stopPropagation();
            // 先隐藏菜单
            if (menuMain) menuMain.style.display = "none";
            if (titleList) titleList.style.display = "none";
            // 获取目标元素的 ID
            const targetId = linkElement.getAttribute('href').substring(1);
            const targetElement = document.getElementById(targetId);
            // 等待 DOM 更新
            await new Promise(resolve => requestAnimationFrame(resolve));
            // 滚动到目标位置
            if (targetElement) {
              targetElement.scrollIntoView({
                behavior: "smooth",
                block: "start"
              });
            }
          });
        }
      });
    };
      // 3. 绑定关闭按钮事件
      const bindCloseButton = () => {
        const closeButton = document.querySelector(".phpgenera_Details_mainR1_close");
        const container = document.querySelector(".phpgenera_Details_mainR1");
        if (closeButton && container) {
          closeButton.addEventListener("click", (event) => {
            event.preventDefault();
            container.style.display = "none";
          });
        }
      };
      // 4. 初始化菜单交互功能
      const initMenuInteraction = () => {
        const menuGroupElements = document.querySelectorAll('.layui-menu-item-group');
        menuGroupElements.forEach(menuItem => {
          menuItem.addEventListener('click', function(event) {
            if (event.target.closest('.m_menusnames')) {
              return;
            }
            this.classList.toggle('layui-menu-item-down');
            this.classList.toggle('layui-menu-item-up');
            const subMenuContainer = this.querySelector('.m_menusnames');
            const icon = this.querySelector('.layui-icon');
            if (subMenuContainer && icon) {
              if (this.classList.contains('layui-menu-item-down')) {
                subMenuContainer.style.display = 'block';
                icon.classList.remove('layui-icon-down');
                icon.classList.add('layui-icon-up');
              } else {
                subMenuContainer.style.display = 'none';
                icon.classList.remove('layui-icon-up');
                icon.classList.add('layui-icon-down');
              }
            }
          });
        });
      };
      // 5. 初始化 layui 功能
      const initLayui = () => {
        if (typeof layui !== 'undefined') {
          layui.use(function () {
            var util = layui.util;
            if (util && util.fixbar) {
              util.fixbar({
                on: {
                  mouseenter: function (type) {
                    if (layer && layer.tips) {
                      layer.tips(type, this, {
                        tips: 4,
                        fixed: true,
                      });
                    }
                  },
                  mouseleave: function (type) {
                    if (layer && layer.closeAll) {
                      layer.closeAll("tips");
                    }
                  },
                },
              });
            }
          });
        }
      };
      // 执行所有初始化函数
      bindMenuEvents();
      bindScrollLinks();
      bindCloseButton();
      initMenuInteraction();
      initLayui();
    });
        </script></body></html>