js DOM節點

===========================元素節點? 4種方式獲取====================

var oDiv = document.getElementById("box");        //通過Id獲取元素
var oDiv = document.getElementsByClassName("div")[0];   //通過類名獲取元素  --》[ 0 ] 必須寫
var oDiv = document.getElementsByTagName("div")[0];    //通過標簽名獲取元素? ?--》[ 0 ] 必須寫
var oDiv = document.getElementsByName("nana")[1];    //通過名字獲取元素 ???--》[ 1 ] 必須寫

?

?

?

===========================獲取節點所有的子節點====================

<div id="box" class="div" style="width: 30px;height: 50px;" name="nana">我是一個文本節點<!--我是注釋節點-->

  <span name="nana" class="div">我是一個span標簽</span>

</div>

?

var oDivChilds = oDiv.childNodes;?

console.log( oDiv.attributes );

{0: name, 1: class,   name: name, class: class}

?

?

?

===========================獲取元素節點的屬性節點====================

var oDivAttris = oDiv.attributes;
console.log( oDivAttris[0].nodeName,oDivAttris[0].nodeValue,oDivAttris[0].nodeType);

name nana 2

?

轉載于:https://www.cnblogs.com/wang1ming/p/10235906.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/278502.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/278502.shtml
英文地址,請注明出處:http://en.pswp.cn/news/278502.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

python web scraping

2019獨角獸企業重金招聘Python工程師標準>>> 最近在看《Web Scraping with Python》&#xff0c;借此來熟悉Python2.7如何開始編程。 發現書上主要使用的 http://example.webscraping.com/ 網站有部分變化&#xff0c;書中的代碼有點無法對照使用&#xff0c;因此稍…

傅里葉變換的物理意義

用三角函數表示周期函數 傅里葉的相關理論始于下面假設&#xff1a;對于周期為1的信號$f(t)$&#xff0c;可以由不同頻率的三角函數組成&#xff0c; $f(t) \frac{a_0}{2}\displaystyle{\sum^{\infty}_{k1}}(a_kcos(2\pi kt)b_ksin(2\pi kt))$ 組成的基礎波形為一個信號對&…

天貓年度總結

2019獨角獸企業重金招聘Python工程師標準>>> 魯大師天貓工作總結 時間&#xff1a;2017年10月22日-1月30日 1、對代理商進行6大區域的劃分管理&#xff0c;有專門的客服指導。 2、加班費申請和車費報銷制度。 3、簡化了特權訂金2階段改成1階段&#xff0c;極大的方便…

因特網使用期限_Internet死亡時使用PC的其他方式

因特網使用期限Nothing is more annoying than getting your Internet connection shut down, due to weather, or perhaps forgetting to pay your bill. Let’s take a look at some ways you can be productive and entertained without the Internet. 沒有什么比由于天氣原…

【基礎操作】線性基詳解

線性基是一個奇妙的集合&#xff08;我摘的原話&#xff09; 這里以非 $OI$ 的角度介紹了線性基 基礎部分 模板題 給你 $n$ 個數的集合&#xff0c;讓你選出任意多個不重復的數&#xff0c;使得它們的異或和最大。 線性基是什么 我們稱集合 $B$ 是集合 $S$ 的線性基&#xff0c…

節省大量教科書的三種潛在風險方法

Photo by Sultry 攝影&#xff1a; Sultry You can always save money on textbooks by buying online, going ebook, or renting what you need. But there are riskier ways to save a buck that just may yield even greater payoff, such as getting the international or …

解決內網搭建本地yum倉庫。

2019獨角獸企業重金招聘Python工程師標準>>> 一、使用iso鏡像搭建本地yum倉庫&#xff1b; 1、掛載鏡像到/mnt目錄下&#xff1a; [rootDasoncheng ~]# mount /dev/cdrom /mnt mount: /dev/sr0 is write-protected, mounting read-only2、備份配置文件&#xff0c;并…

通過用 .NET 生成自定義窗體設計器來定制應用程序

本文討論&#xff1a; ? 設計時環境基本原理 ? 窗體設計器體系結構 ? Visual Studio .NET 中窗體設計器的實現 ? 為自己的應用程序編寫窗體設計器而需要實現的服務 在很多年中&#xff0c;MFC 一直是生成基于 Windows? 的應用程序的流行框架。MFC 包含一個可以使窗體生成、…

airdrop 是 藍牙嗎_您可以在Windows PC或Android手機上使用AirDrop嗎?

airdrop 是 藍牙嗎Aleksey Khilko/Shutterstock.comAleksey Khilko / Shutterstock.comApple’s AirDrop is a convenient way to send photos, files, links, and other data between devices. AirDrop only works on Macs, iPhones, and iPads, but similar solutions are av…

vue加百度統計代碼(親測有效)

申請百度統計后&#xff0c;會得到一段JS代碼&#xff0c;需要插入到每個網頁中去&#xff0c;在Vue.js項目首先想到的可能就是&#xff0c;把統計代碼插入到index.html入口文件中&#xff0c;這樣就全局插入&#xff0c;每個頁面就都有了;這樣做就涉及到一個問題&#xff0c;V…

如何將Rant變成生產力電動工具

Ranting doesn’t have to be a waste of breathe and time. You can turn a rant into a powerful tool for productivity. Learn how to transform your sense of victim hood and irritability to self-empowerment and mental clarity. 狂歡不必浪費呼吸和時間。 您可以將r…

linux 下使用 curl post

命令&#xff1a; curl -X POST -d /etc/lazada/lazada_tracking.txt http://localhost:8080/booking/rs/LazadaService/post --header "Content-Type:application/json" -d 后臺 / &#xff1a; post 的 body 體 &#xff45;&#xff47;&#xff1a; {"a…

服務治理·理論篇(一)

0、故事主角 呱呱樂 是一家互聯網金融公司。主營現金貸、p2p理財、消費分期業務。 公司現有技術人員800名&#xff0c;系統極其龐雜&#xff0c;每日穩定處理25w左右的訂單量&#xff0c;有搶購活動時&#xff0c;系統的QPS(Query Per Second)峰值達到了3w。 系統雖然龐雜&…

2019-1-92.4G射頻芯片培訓資料

2019-1-92.4G射頻芯片培訓資料 培訓 RF 小書匠 歡迎走進zozo的學習之旅。 2.4G芯片選型2.4G芯片開發Q&A2.4G芯片選型 芯片類型 soc防盜標簽2.4G無線芯片選型發射器收發器LSD2RF-1600-V1.1 調制方式射頻基礎 2.4G芯片開發 原理圖 發射優先收發均衡PCB topbottomlayout規…

在Outlook 2010中使用對話視圖

One of the new features in Outlook 2010 is the ability to use Conversation View for easier management of your email conversations. Here we will take a quick look at how to use the new feature. Outlook 2010中的新功能之一是可以使用“對話視圖”來更輕松地管理電…

openresty capture

local args {} args["name"] "張三" args["sex"] "男"local captureRes; if ngx.var.request_method "POST" thencaptureRes ngx.location.capture(/dsideal_yy/test, {method ngx.HTTP_POST, headers { ["Cont…

Day10:html和css

Day10:html和css <html> <body> <h1>標題</h1> <p>段落</p> </body> </html>HTML 是用來描述網頁的一種語言&#xff0c;超文本標記語言&#xff0c;不是一種編程語言&#xff0c;而是一種標記語言&#xff0c;是一套標記標簽…

如何在PowerPoint演示文稿中使用iTunes音樂

One of PowerPoint’s charms is its ability to play music during the presentation. Adding music to your presentation is simple, but using a song from your iTunes library requires a few extra steps. Here’s how to use iTunes music in PowerPoint. PowerPoint的…

Android:DELETE_FAILED_INTERNAL_ERROR Error while Installing APKs

Android studio DELETE_FAILED_INTERNAL_ERROR Error while Installing APKs 一、報錯信息 DELETE_FAILED_INTERNAL_ERRORError while Installing APKs 二、報錯原因 在一些機型上安裝軟件 提示卸載原先的軟件 但是又安裝不上新軟件 三、解決方法&#xff1a; File->Settin…

hotmail_在新的Hotmail Wave 4中禁用Messenger

hotmailAre you annoyed by having Messenger automatically sign in when you’re reading your emails in the new Hotmail? Here’s how you can disable the Web Messenger in Hotmail and other Windows Live online apps. 當您在新的Hotmail中閱讀電子郵件時&#xff0…