SlideShare a Scribd company logo
HTML
Data attributes
by yz
<div	
  id="following_list",	
  class=“list”>
	
  	
  //code
</div>
14年6月6日金曜日
HTML
Data attributes
by yz
14年6月6日金曜日
HTML
Data attributes
by yz
<div	
  id="following_list",	
  class=“list”	
  
	
  data-­‐list-­‐size	
  =	
  “10”	
  data-­‐column	
  =	
  “2”>
	
  	
  //code
</div>
14年6月6日金曜日
What it is
• HTML5 syntax to store information on
HTML elements
14年6月6日金曜日
What the syntax looks like
in HTML tag
data-something = “anything”
14年6月6日金曜日
What the syntax looks like
in HTML tag
data-something = “anything”
14年6月6日金曜日
What the syntax looks like
in HTML tag
data-something = “anything”
all-lowercase
14年6月6日金曜日
What the syntax looks like
in HTML tag
data-something = “anything”
all-lowercase
the attribute value can be any string
14年6月6日金曜日
What it is used for
• to store the initial value of an element
ex.) height, opacity, the size of the list
14年6月6日金曜日
What it is used for
• to store the initial value of an element
ex.) height, opacity, the size of the list
... which might be required in later JavaScript
animation calculations etc.
14年6月6日金曜日
What it is used for
• to store the initial value of an element
ex.) height, opacity, the size of the list
... which might be required in later JavaScript
animation calculations etc.
<div id= “follow_list” data-list-size = ’10’> <div>
14年6月6日金曜日
How to use it
• in JavaScript
// Getting all the data-attributes using dataset
14年6月6日金曜日
How to use it
• in JavaScript
// Getting all the data-attributes using dataset
14年6月6日金曜日
How to use it
• in JavaScript
// Getting all the data-attributes using dataset
14年6月6日金曜日
How to use it
• in JavaScript
// 'Getting' data-attributes using getAttribute
// 'Setting' data-attributes using setAttribute
<div id='strawberry-plant' data-fruit='12'></div>
14年6月6日金曜日
How to use it
• in JavaScript
// 'Getting' data-attributes using getAttribute
// 'Setting' data-attributes using setAttribute
var plant = document.getElementById('strawberry-plant');
var fruitCount = plant.getAttribute('data-fruit');
// fruitCount = '12'
<div id='strawberry-plant' data-fruit='12'></div>
14年6月6日金曜日
How to use it
• in JavaScript
// 'Getting' data-attributes using getAttribute
// 'Setting' data-attributes using setAttribute
var plant = document.getElementById('strawberry-plant');
var fruitCount = plant.getAttribute('data-fruit');
// fruitCount = '12'
plant.setAttribute('data-fruit','7');
<div id='strawberry-plant' data-fruit='12'></div>
14年6月6日金曜日
How to use it
• in CSS
14年6月6日金曜日
How to use it
• in CSS
change styles
according to data!
14年6月6日金曜日
Summary
• When your JavaScript/CSS code is messed up with
HTML classes, use data attributes!
• Just insert data-something = “anything” in your
HTML tag!
• JavaScript -
• CSS -
• I will post this presentation on Google + community :)
• links: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes
http://html5doctor.com/html5-custom-data-attributes/
14年6月6日金曜日
Summary
• When your JavaScript/CSS code is messed up with
HTML classes, use data attributes!
• Just insert data-something = “anything” in your
HTML tag!
• JavaScript -
• CSS -
• I will post this presentation on Google + community :)
• links: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes
http://html5doctor.com/html5-custom-data-attributes/
dataset, getAttributes, setAttributes
14年6月6日金曜日
Summary
• When your JavaScript/CSS code is messed up with
HTML classes, use data attributes!
• Just insert data-something = “anything” in your
HTML tag!
• JavaScript -
• CSS -
• I will post this presentation on Google + community :)
• links: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes
http://html5doctor.com/html5-custom-data-attributes/
dataset, getAttributes, setAttributes
tagname[data-x = “y”]
14年6月6日金曜日

More Related Content

Similar to Lt html data_attributes

Exploring the Sweet Spot: Geolocation, Health, and Gov-data
Exploring the Sweet Spot: Geolocation, Health, and Gov-data Exploring the Sweet Spot: Geolocation, Health, and Gov-data
Exploring the Sweet Spot: Geolocation, Health, and Gov-data
Lance Roggendorff
 
Google charts
Google chartsGoogle charts
Google charts
maikroeder
 
Linked Data Presentation at TDWI Mpls
Linked Data Presentation at TDWI MplsLinked Data Presentation at TDWI Mpls
Linked Data Presentation at TDWI Mpls
Jay Myers
 
Energizing Social Commerce with Open Graph
Energizing Social Commerce with Open GraphEnergizing Social Commerce with Open Graph
Energizing Social Commerce with Open Graph
Praveen Alavilli
 
Searching the Web of Data (Tutorial)
Searching the Web of Data (Tutorial)Searching the Web of Data (Tutorial)
Searching the Web of Data (Tutorial)
Gerard de Melo
 
Advanced Structured Data: Beyond Rich Snippets
Advanced Structured Data: Beyond Rich SnippetsAdvanced Structured Data: Beyond Rich Snippets
Advanced Structured Data: Beyond Rich Snippets
Justin Briggs
 
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Balázs Tatár
 
Angular js, Yeomon & Grunt
Angular js, Yeomon & GruntAngular js, Yeomon & Grunt
Angular js, Yeomon & Grunt
Richard Powell
 
spring3.2 java config Servler3
spring3.2 java config Servler3spring3.2 java config Servler3
spring3.2 java config Servler3
YongHyuk Lee
 
Options, and Transients, and Theme Mods — Oh my!
Options, and Transients, and Theme Mods — Oh my!Options, and Transients, and Theme Mods — Oh my!
Options, and Transients, and Theme Mods — Oh my!
Konstantin Obenland
 
Php frameworks
Php frameworksPhp frameworks
Php frameworks
Anil Kumar Panigrahi
 
Magento Attributes - Fresh View
Magento Attributes - Fresh ViewMagento Attributes - Fresh View
Magento Attributes - Fresh View
Alex Gotgelf
 
SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3
SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3
SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3
Vasilij Nevlev
 
AtlasCamp 2013: Modernizing your Plugin UI
AtlasCamp 2013: Modernizing your Plugin UI AtlasCamp 2013: Modernizing your Plugin UI
AtlasCamp 2013: Modernizing your Plugin UI
colleenfry
 
When you need more data in less time...
When you need more data in less time...When you need more data in less time...
When you need more data in less time...
Bálint Horváth
 
Building High Performance and Reliable Windows Phone 8 Apps
Building High Performance and Reliable Windows Phone 8 AppsBuilding High Performance and Reliable Windows Phone 8 Apps
Building High Performance and Reliable Windows Phone 8 Apps
Michele Capra
 
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Michael Wales
 
Drupal 8 configuration system for coders and site builders - Drupalaton 2013
Drupal 8 configuration system for coders and site builders - Drupalaton 2013Drupal 8 configuration system for coders and site builders - Drupalaton 2013
Drupal 8 configuration system for coders and site builders - Drupalaton 2013
swentel
 
Android Data Binding from zero
Android Data Binding from zeroAndroid Data Binding from zero
Android Data Binding from zero
Seyyed davud hosseiny
 
สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1
ทวิร พานิชสมบัติ
 

Similar to Lt html data_attributes (20)

Exploring the Sweet Spot: Geolocation, Health, and Gov-data
Exploring the Sweet Spot: Geolocation, Health, and Gov-data Exploring the Sweet Spot: Geolocation, Health, and Gov-data
Exploring the Sweet Spot: Geolocation, Health, and Gov-data
 
Google charts
Google chartsGoogle charts
Google charts
 
Linked Data Presentation at TDWI Mpls
Linked Data Presentation at TDWI MplsLinked Data Presentation at TDWI Mpls
Linked Data Presentation at TDWI Mpls
 
Energizing Social Commerce with Open Graph
Energizing Social Commerce with Open GraphEnergizing Social Commerce with Open Graph
Energizing Social Commerce with Open Graph
 
Searching the Web of Data (Tutorial)
Searching the Web of Data (Tutorial)Searching the Web of Data (Tutorial)
Searching the Web of Data (Tutorial)
 
Advanced Structured Data: Beyond Rich Snippets
Advanced Structured Data: Beyond Rich SnippetsAdvanced Structured Data: Beyond Rich Snippets
Advanced Structured Data: Beyond Rich Snippets
 
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019
 
Angular js, Yeomon & Grunt
Angular js, Yeomon & GruntAngular js, Yeomon & Grunt
Angular js, Yeomon & Grunt
 
spring3.2 java config Servler3
spring3.2 java config Servler3spring3.2 java config Servler3
spring3.2 java config Servler3
 
Options, and Transients, and Theme Mods — Oh my!
Options, and Transients, and Theme Mods — Oh my!Options, and Transients, and Theme Mods — Oh my!
Options, and Transients, and Theme Mods — Oh my!
 
Php frameworks
Php frameworksPhp frameworks
Php frameworks
 
Magento Attributes - Fresh View
Magento Attributes - Fresh ViewMagento Attributes - Fresh View
Magento Attributes - Fresh View
 
SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3
SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3
SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3
 
AtlasCamp 2013: Modernizing your Plugin UI
AtlasCamp 2013: Modernizing your Plugin UI AtlasCamp 2013: Modernizing your Plugin UI
AtlasCamp 2013: Modernizing your Plugin UI
 
When you need more data in less time...
When you need more data in less time...When you need more data in less time...
When you need more data in less time...
 
Building High Performance and Reliable Windows Phone 8 Apps
Building High Performance and Reliable Windows Phone 8 AppsBuilding High Performance and Reliable Windows Phone 8 Apps
Building High Performance and Reliable Windows Phone 8 Apps
 
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
 
Drupal 8 configuration system for coders and site builders - Drupalaton 2013
Drupal 8 configuration system for coders and site builders - Drupalaton 2013Drupal 8 configuration system for coders and site builders - Drupalaton 2013
Drupal 8 configuration system for coders and site builders - Drupalaton 2013
 
Android Data Binding from zero
Android Data Binding from zeroAndroid Data Binding from zero
Android Data Binding from zero
 
สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1
 

Recently uploaded

Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 

Recently uploaded (20)

Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 

Lt html data_attributes

  • 1. HTML Data attributes by yz <div  id="following_list",  class=“list”>    //code </div> 14年6月6日金曜日
  • 3. HTML Data attributes by yz <div  id="following_list",  class=“list”    data-­‐list-­‐size  =  “10”  data-­‐column  =  “2”>    //code </div> 14年6月6日金曜日
  • 4. What it is • HTML5 syntax to store information on HTML elements 14年6月6日金曜日
  • 5. What the syntax looks like in HTML tag data-something = “anything” 14年6月6日金曜日
  • 6. What the syntax looks like in HTML tag data-something = “anything” 14年6月6日金曜日
  • 7. What the syntax looks like in HTML tag data-something = “anything” all-lowercase 14年6月6日金曜日
  • 8. What the syntax looks like in HTML tag data-something = “anything” all-lowercase the attribute value can be any string 14年6月6日金曜日
  • 9. What it is used for • to store the initial value of an element ex.) height, opacity, the size of the list 14年6月6日金曜日
  • 10. What it is used for • to store the initial value of an element ex.) height, opacity, the size of the list ... which might be required in later JavaScript animation calculations etc. 14年6月6日金曜日
  • 11. What it is used for • to store the initial value of an element ex.) height, opacity, the size of the list ... which might be required in later JavaScript animation calculations etc. <div id= “follow_list” data-list-size = ’10’> <div> 14年6月6日金曜日
  • 12. How to use it • in JavaScript // Getting all the data-attributes using dataset 14年6月6日金曜日
  • 13. How to use it • in JavaScript // Getting all the data-attributes using dataset 14年6月6日金曜日
  • 14. How to use it • in JavaScript // Getting all the data-attributes using dataset 14年6月6日金曜日
  • 15. How to use it • in JavaScript // 'Getting' data-attributes using getAttribute // 'Setting' data-attributes using setAttribute <div id='strawberry-plant' data-fruit='12'></div> 14年6月6日金曜日
  • 16. How to use it • in JavaScript // 'Getting' data-attributes using getAttribute // 'Setting' data-attributes using setAttribute var plant = document.getElementById('strawberry-plant'); var fruitCount = plant.getAttribute('data-fruit'); // fruitCount = '12' <div id='strawberry-plant' data-fruit='12'></div> 14年6月6日金曜日
  • 17. How to use it • in JavaScript // 'Getting' data-attributes using getAttribute // 'Setting' data-attributes using setAttribute var plant = document.getElementById('strawberry-plant'); var fruitCount = plant.getAttribute('data-fruit'); // fruitCount = '12' plant.setAttribute('data-fruit','7'); <div id='strawberry-plant' data-fruit='12'></div> 14年6月6日金曜日
  • 18. How to use it • in CSS 14年6月6日金曜日
  • 19. How to use it • in CSS change styles according to data! 14年6月6日金曜日
  • 20. Summary • When your JavaScript/CSS code is messed up with HTML classes, use data attributes! • Just insert data-something = “anything” in your HTML tag! • JavaScript - • CSS - • I will post this presentation on Google + community :) • links: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes http://html5doctor.com/html5-custom-data-attributes/ 14年6月6日金曜日
  • 21. Summary • When your JavaScript/CSS code is messed up with HTML classes, use data attributes! • Just insert data-something = “anything” in your HTML tag! • JavaScript - • CSS - • I will post this presentation on Google + community :) • links: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes http://html5doctor.com/html5-custom-data-attributes/ dataset, getAttributes, setAttributes 14年6月6日金曜日
  • 22. Summary • When your JavaScript/CSS code is messed up with HTML classes, use data attributes! • Just insert data-something = “anything” in your HTML tag! • JavaScript - • CSS - • I will post this presentation on Google + community :) • links: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes http://html5doctor.com/html5-custom-data-attributes/ dataset, getAttributes, setAttributes tagname[data-x = “y”] 14年6月6日金曜日