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
43
仮想電子工作のすすめ
ckazu
0
61
ウェブエンジニアのための色の話
ckazu
0
31
これさえ読めば知ったかできるかもしれない人工知能の歴史と機械学習の今
ckazu
0
35
Shinjuku.html5.lunch #11
ckazu
0
46
typo の傾向と対策
ckazu
0
40
ずぶの素人がRails開発できるようになるために必要な5つのこと
ckazu
0
47
Other Decks in Programming
See All in Programming
『コードを書く以外の』エンジニアリング〜課金基盤移行プロジェクト推進のためのTips4選
yuriko1211
0
550
霧の中の代数的エフェクト
funnyycat
1
440
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
200
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
240
【やさしく解説 設計編・中級 #4】ルールの寿命と、システムの年輪
panda728
PRO
2
170
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
0
340
自作OSでスライド発表する
uyuki234
1
4k
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
280
【やさしく解説 設計編 #0】DDDのコード、読めるのに分からない人へ
panda728
PRO
2
280
AIが無かった頃の素敵な出会いの話
codmoninc
1
270
型も通る、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
460
Apache Hive: Toward a Cloud Native Lakehouse
okumin
0
160
Featured
See All Featured
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
360
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
67
56k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
570
Six Lessons from altMBA
skipperchong
29
4.4k
We Are The Robots
honzajavorek
0
290
Joys of Absence: A Defence of Solitary Play
codingconduct
1
420
How GitHub (no longer) Works
holman
316
150k
Thoughts on Productivity
jonyablonski
76
5.3k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
880
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
GraphQLとの向き合い方2022年版
quramy
50
15k
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