Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jquery get data attribute value

/* html */
<a data-id="123">link</a>

/* js */
$(this).attr("data-id") // returns string "123"

$(this).data("id") // returns number 123 (jQuery >= 1.4.3 only)
Comment

jquery select by data attribute

$('div[data-key=value]');
Comment

jquery data attribute

/* html */
<a data-number="123">link</a>

/* js */
$(this).attr("data-number") // returns string "123"

$(this).data("number") // returns number 123 (jQuery >= 1.4.3 only)
Comment

find element with data attribute jquery

$("ul").find(`[data-slide='${current}']`)
Comment

jquery find by data attribute

$('.slide-link[data-slide="0"]').addClass('active');
Comment

jquery get data attribute

<a data-id="123">link</a>


var id = $(this).data("id"); // Will set id to 123
Comment

jquery find div with data attribute value

$("body").find("[data-searchme='" + var_value + "']"); 
Comment

jquery get data attribute

$('input[type=radio][name=supplier_price]').change(function () {
            var $id                   = $(this).val(),
                $price                = $(this).data('price'),
                $intend_price         = $(this).data('intend-price'),
                $product__month_price = $('#product__month_price'),
                $product_price        = $('#product_price');

            console.log($price, $intend_price);

        });
Comment

How get current data attribute value in jQuery?

<div id="123" data-img-flag="1">
	<image src="abc.png">
</div>

<div id="432" data-img-flag="0">
	<image src="abc.png">
</div>
<script>
alert($(popImgId).data('img-flag')); // when we use data function to get the data attribute value wll get all time value loaded at the time of DOM loaded
alert($(popImgId).attr('data-img-flag')); // value will get lates. If we change/update value using jquery will get updated value 
</script>
Comment

jquery get all data attributes values

$('#prod').data()
Comment

jquery get element by data attribute

$("ul[data-slide='" + current +"']");
Comment

jquery get data attribute value by class

//get the result as array
<option value="<?php echo $value['id']; ?>" data-count="5">
</option>

var data = $('.myclass').map(function() {
    return $(this).data('optionid');
}).get();
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to change css using javascript 
Javascript :: fabric js 
Javascript :: filter the falsy values out of an array in a very simple way! 
Javascript :: https request node.js output incomplete 
Javascript :: recover form data in json 
Javascript :: Replace empty strings in object with null values 
Javascript :: change the origin of html canvas 
Javascript :: div diseapear animation 
Javascript :: split by space capital letter or underscore javascript 
Javascript :: material icons angular 
Javascript :: python run javascript 
Javascript :: JSON.stringify() function converts buffers into objects. The raw data is encoded as an array of bytes that you can pass in to Buffer.from(). 
Javascript :: create java script array 
Javascript :: node js hello word 
Javascript :: empty array js 
Javascript :: javascript check type of variable var 
Javascript :: add image inside a div on specific position javascript 
Javascript :: how to generate random gradient javascript 
Javascript :: ejs tutorial 
Javascript :: javascript function call with variable 
Javascript :: type conversions in javascript 
Javascript :: Get Country from the international phone number 
Javascript :: vue js qr code scanner 
Javascript :: html select multiple selected values 
Javascript :: app.router.navigate reset framework7 
Javascript :: codeceptjs "waitForClickable" 
Javascript :: javascript true string to boolean 
Javascript :: react function runs several times 
Javascript :: slice in javascript 
Javascript :: graphql yoga access http headers 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =