Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Query selecterの話
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
ckazu
June 01, 2017
Programming
37
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Query selecterの話
https://www.slideshare.net/ckazu/query-selecter
ckazu
June 01, 2017
More Decks by ckazu
See All by ckazu
2024 コーディング研修
ckazu
2
1.9k
磯野家で学ぶ Prolog
ckazu
0
44
Introduction fasttext
ckazu
0
45
仮想電子工作のすすめ
ckazu
0
61
ウェブエンジニアのための色の話
ckazu
0
32
これさえ読めば知ったかできるかもしれない人工知能の歴史と機械学習の今
ckazu
0
36
Shinjuku.html5.lunch #11
ckazu
0
47
typo の傾向と対策
ckazu
0
55
ずぶの素人がRails開発できるようになるために必要な5つのこと
ckazu
0
47
Other Decks in Programming
See All in Programming
Dockerfile CMD for Node.js
grazie1999
0
120
片田舎のおっさん、 Swift Buildのダイアモンド問題解決の不具合修正PRを出すが、解決方法がキャッシュをしないようにすることであり、ビルド時間が伸びると言われてマージされないので高速化もする/swiftbuild
yimajo
0
250
PostgreSQL 18で考えるUUID主キー
kazuhiro1982
0
500
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
270
Discordを用いたラボオートメーション関連情報収集の自動化
noguhiro2002
0
380
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
350
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
200
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
240
楽しそうなつよつよエンジニアと目が死んでる僕/A brilliant engineer having a blast, and dead-eyed me.
3l4l5
2
240
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
720
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4k
リアルな遅延を測る仕様
kota_yata
1
120
Featured
See All Featured
Game over? The fight for quality and originality in the time of robots
wayneb77
1
250
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
430
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.8k
A better future with KSS
kneath
240
18k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Believing is Seeing
oripsolob
1
200
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
550
How to build a perfect <img>
jonoalderson
1
5.9k
Crafting Experiences
bethany
1
260
Being A Developer After 40
akosma
91
590k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
420
Transcript
jQuery Javascript CSS selector 2017/06/01 LT
5
<table id="score"> <thead> <tr> <th>Test <th>Result <tfoot> <tr> <th>Average <td>??
<tbody> <tr> <td>A <td>87% <tr> <td>B <td>78% <tr> <td>Z <td>81% </table> Test Result Average ?? A 87% B 78% ... ... Z 81%
<table id="score"> <thead> <tr> <th>Test <th>Result <tfoot> <tr> <th>Average <td>??
<tbody> <tr> <td>A <td>87% <tr> <td>B <td>78% <tr> <td>Z <td>81% </table> Test Result Average ?? A 87% B 78% ... ... Z 81% chrome console ↑
<table id="score"> <thead> <tr> <th>Test <th>Result <tfoot> <tr> <th>Average <td>??
<tbody> <tr> <td>A <td>87% <tr> <td>B <td>78% <tr> <td>C <td>81% </table> var table = document.getElementById("score"); var groups = table.tBodies; var rows = null; var cells = []; for (var i = 0; i < groups.length; i++) { rows = groups[i].rows; for (var j = 0; j < rows.length; j++) { cells.push(rows[j].cells[1]); } } console.log(cells); > (3) [td, td, td] Pure Javascript
jQuery > jQuery("#score > tbody > tr td:nth‐of‐type(2)") >> (3)
[td, td, td, prevObject: r.fn.init(1)] > jQuery("#score > tbody > tr td:nth‐of‐type(2)").text() >> "87% >> 78% >> 81% >> " ※ #score > tbody > tr td + td OK var _j = document.createElement('script'); _j.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery. document.body.appendChild(_j);
jQuery
XPath !!!
XML Path Language (XPath) => https://www.w3.org/TR/xpath/
XPath > $x('//table/tbody/tr/td[count(preceding‐sibling::td) = 1]') >> (3) [td, td, td]
> $x('//table/tbody/tr/td[count(preceding‐sibling::td) = 1]')[0 >> <td> 87% >> </td>
CSS selector ... jQue..
Selectors API by W3C http://www.w3.org/TR/2013/REC‑selectors‑api‑20130221/ Previous Versions: http://www.w3.org/TR/2012/PR‑selectors‑api‑20121213/ http://www.w3.org/TR/2012/WD‑selectors‑api‑20120628/ http://www.w3.org/TR/2009/CR‑selectors‑api‑20091222/
http://www.w3.org/TR/2008/WD‑selectors‑api‑20081114/ http://www.w3.org/TR/2007/WD‑selectors‑api‑20071221/ http://www.w3.org/TR/2007/WD‑selectors‑api‑20071019/ http://www.w3.org/TR/2006/WD‑selectors‑api‑20060926/ http://www.w3.org/TR/2006/WD‑selectors‑api‑20060525/
Selectors API partial interface Document { Element? querySelector(DOMString selectors); NodeList
querySelectorAll(DOMString selectors); }; partial interface DocumentFragment { Element? querySelector(DOMString selectors); NodeList querySelectorAll(DOMString selectors); }; partial interface Element { Element? querySelector(DOMString selectors); NodeList querySelectorAll(DOMString selectors); };
Selectors API Element.querySelectorAll(DOMString selectors); ↑ CSS selectors https://www.w3.org/TR/css3‑selectors/
querySelectorAll() > document.querySelectorAll('#score > tbody > tr td:nth‐of‐type(2)' >> (3)
[td, td, td] > document.querySelectorAll('#score > tbody > tr td:nth‐of‐type(2)' >> <td> 87% >> </td>
querySelectorAll() jQuery > jQuery("#score > tbody > tr td:nth‐of‐type(2)") >>
(3) [td, td, td, prevObject: r.fn.init(1)] > document .querySelectorAll('#score > tbody > tr td:nth‐of‐type(2)') >> (3) [td, td, td]
document.querySelectorAll('table, input:checked')
jQuery 1. getElementById() 2. querySelectorAll() 3. sizzle jQuery
None