$(this).data('type') code example
Example 1: data types in javascript
var strSingle = 'John';
var strDouble = "Bob";
var num = 25;
var flo = 80.5;
var exp = 4.25e+6;
var isReading = true;
var isSleeping = false;
var undef;
var noValue = null;
var emptyObject = {};
var person = {"name": "Clark", "surname": "Kent", "age": "36"};
var car = {
model: "BMW X3",
color: "white",
doors: 5
}
var emptyArray = [];
var array = ["One", "Two"]
var func = function() {
alert("Code excuted");
}
var funcVar = function(amount) {
alert("Code excuted " + amount + " times");
}
typeof variable;
Example 2: jquery data attribute
data attribute in jquery
For setting attribute data to the element
Html
<p id="assign">Assigning data attribute</p>
jquery
$("#assign").data("title","firstparagraph");
Output:
<p id="assign" data-title="firstparagraph">Assigning data attribute</p>
For getting attribute data from the element
Html
<p id="assign" data-title="firstparagraph">Assigning data attribute</p>
jquery
console.log($("#assign").data("title"));
console.log($("#assign").data());
Output:
firstparagraph
{ title: firstparagraph }