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
32
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
42
Introduction fasttext
ckazu
0
40
仮想電子工作のすすめ
ckazu
0
58
ウェブエンジニアのための色の話
ckazu
0
29
これさえ読めば知ったかできるかもしれない人工知能の歴史と機械学習の今
ckazu
0
33
Shinjuku.html5.lunch #11
ckazu
0
44
typo の傾向と対策
ckazu
0
36
ずぶの素人がRails開発できるようになるために必要な5つのこと
ckazu
0
46
Other Decks in Programming
See All in Programming
Inside Stream API
skrb
1
750
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
スマートグラスで並列バイブコーディング
hyshu
0
250
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
600
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
11
6k
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
890
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
210
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
550
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
7.3k
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
270
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.7k
Featured
See All Featured
The Limits of Empathy - UXLibs8
cassininazir
1
370
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Git: the NoSQL Database
bkeepers
PRO
432
67k
30 Presentation Tips
portentint
PRO
1
330
How to build a perfect <img>
jonoalderson
1
5.7k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
310
KATA
mclloyd
PRO
35
15k
Google's AI Overviews - The New Search
badams
0
1k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
170
Typedesign – Prime Four
hannesfritz
42
3.1k
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