Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

data-id html javascript

<div id='strawberry-plant' data-fruit='12'></div>

<script>
// 'Getting' data-attributes using getAttribute
var plant = document.getElementById('strawberry-plant');
var fruitCount = plant.getAttribute('data-fruit'); // fruitCount = '12'

// 'Setting' data-attributes using setAttribute
plant.setAttribute('data-fruit','7'); // Pesky birds
</script>
Comment

data id tag

var dataId = $(this).attr("data-id");
Comment

PREVIOUS NEXT
Code Example
Javascript :: header logo react native img 
Javascript :: regex search for all math operators 
Javascript :: javascript get referrer 
Javascript :: random id generator javascript 
Javascript :: switch case in javascript 
Javascript :: js sort letters 
Javascript :: jquery remove css 
Javascript :: react js download file 
Javascript :: remove repeated characters from a string in javascript 
Javascript :: angular submit with required 
Javascript :: how to make a game in unity with javascript 
Javascript :: for of js 
Javascript :: spawn template playcanvas 
Javascript :: javascript on window resize 
Javascript :: fs clear directory 
Javascript :: vscode extensions for better react js 
Javascript :: referenceerror document is not defined node js 
Javascript :: react tostify 
Javascript :: reverse every word in a string javascript 
Javascript :: javascript set variable if not defined 
Javascript :: or operator in javascript 
Javascript :: nodejs emit event from class 
Javascript :: downgrade nodejs with nvm 
Javascript :: reload data in datatable 
Javascript :: .net mvc javascript function call link 
Javascript :: javascript select change selected 
Javascript :: react focus textarea 
Javascript :: react google map 
Javascript :: nodejs delete s3 folder 
Javascript :: regex to find emails 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =