SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
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日金曜日

Mais conteúdo relacionado

Semelhante a Lt html data_attributes

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
 
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
 
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
 

Semelhante a 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
 

Último

Último (20)

AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

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日金曜日