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
ckazu
June 01, 2017
Programming
34
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
43
Introduction fasttext
ckazu
0
43
仮想電子工作のすすめ
ckazu
0
61
ウェブエンジニアのための色の話
ckazu
0
31
これさえ読めば知ったかできるかもしれない人工知能の歴史と機械学習の今
ckazu
0
35
Shinjuku.html5.lunch #11
ckazu
0
46
typo の傾向と対策
ckazu
0
54
ずぶの素人がRails開発できるようになるために必要な5つのこと
ckazu
0
47
Other Decks in Programming
See All in Programming
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
260
自動化したのに回らないテスト運用の壁ーAI時代の品質責任と生産性
mfunaki
0
120
音楽のための関数型プログラミング言語mimiumにおける多段階計算の活用
tomoyanonymous
1
380
これって Effect でできたのでは? / TSKaigi Mashup Kansai #2
susisu
0
140
Prismを使った型安全な暗号化_関数型まつり2026
_fhhmm
0
160
型も通る、synthも通る、それでも危ない 〜AIのCDKの権限とコストを機械で検証する〜 / It Passes Type Checks, It Passes Synth Checks, but It’s Still Risky — Automatically Verifying Permissions and Costs in AI’s CDK —
seike460
PRO
1
510
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
12
17k
php-fpmのプロセスが枯渇した日-調査・対処・そして本当にやるべきだったこと-
shibuchaaaan
0
190
yield再入門 #phpcon
o0h
PRO
0
880
琵琶湖の水は止められてもNet--HTTPのリトライは止められない / You might be able to stop the water flow of Lake Biwa but you can't stop Net::HTTP retries
luccafort
PRO
0
520
【やさしく解説 設計編・中級 #4】ルールの寿命と、システムの年輪
panda728
PRO
2
180
Android CLI
fornewid
0
200
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.7k
Music & Morning Musume
bryan
47
7.3k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
1k
Un-Boring Meetings
codingconduct
0
360
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
66
57k
A Soul's Torment
seathinner
6
3.1k
WENDY [Excerpt]
tessaabrams
11
39k
For a Future-Friendly Web
brad_frost
183
10k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
From π to Pie charts
rasagy
0
240
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
230
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