Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Query selecterの話
Search
ckazu
June 01, 2017
Programming
41
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
Transcript
19 slides
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
More Decks by ckazu
See All by ckazu
2024 コーディング研修
ckazu
2
2k
磯野家で学ぶ Prolog
ckazu
0
58
Introduction fasttext
ckazu
0
53
仮想電子工作のすすめ
ckazu
0
68
ウェブエンジニアのための色の話
ckazu
0
37
これさえ読めば知ったかできるかもしれない人工知能の歴史と機械学習の今
ckazu
0
40
Shinjuku.html5.lunch #11
ckazu
0
49
typo の傾向と対策
ckazu
0
61
ずぶの素人がRails開発できるようになるために必要な5つのこと
ckazu
0
52
Other Decks in Programming
See All in Programming
ActionController meets Protocol Buffers
sorah
1
800
Python Lambdaにおけるテストしやすい設計とAI支援の活用 / Designing Testable Python Lambda Functions with AI
kitano_yuichi
1
320
複数ドメインを一つのアプリに統合するFlutterの設計と運用_FlutterKaigi2026登壇資料(須永高弘)
takahirosunaga
0
180
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
330
Claude Code ハーネスDeep Dive – 君はどこまで制御する? -
takateeen_knj
6
5.6k
flutter_test のその先へ — Flutter アプリの LLM 機能に「評価」という品質保証を
kosukesaigusa
0
200
조합이폭발하는디자인시스템이걸눈으로도테스트하라고요
giljongyu
0
750
SODA - FACT BOOK(EN)
sodainc
1
230
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
170
느린 네트워크와 저사양 디바이스 사용자를 위한 웹뷰 로딩 시간 개선기
kmkim
1
230
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
2
300
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
370
Featured
See All Featured
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
580
What's in a price? How to price your products and services
michaelherold
247
13k
Skip the Path - Find Your Career Trail
mkilby
1
290
Java REST API Framework Comparison - PWX 2021
mraible
34
9.8k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.3k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
560
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
680
The Cult of Friendly URLs
andyhume
79
7.1k
Exploring anti-patterns in Rails
aemeredith
4
560
New Earth Scene 8
popppiees
5
2.8k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
470
The Mindset for Success: Future Career Progression
greggifford
PRO
0
560