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 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 :: jquery click or touch 
Javascript :: jquery check scroll direction 
Javascript :: fibonacci sequence in javascript using for loop 
Javascript :: jquery check a radio button 
Javascript :: how to pad string js 
Javascript :: get browser language 
Javascript :: node load string from file 
Javascript :: axios Cross origin http://localhost forbidden 
Javascript :: synchronous ajax 
Javascript :: get value onChange from mat-select angular 
Javascript :: how to set name attribute in jquery 
Javascript :: send a file ajax 
Javascript :: Get First Day and last day of week javascript 
Javascript :: javacript string add space after commas 
Javascript :: javascript uppercase first character of each word 
Javascript :: axios delete is throwing cors error 
Javascript :: jquery check if input is empty on submit 
Javascript :: parsefloat jquery 
Javascript :: how to root with any number in js 
Javascript :: Javascript track mouse pointer 
Javascript :: jsx 
Javascript :: node read file line 
Javascript :: creating new react app 
Javascript :: array sum javascript 
Javascript :: javascript promise sleep 
Javascript :: jquery clear select 2 
Javascript :: validador de cep javascript 
Javascript :: console log add new line 
Javascript :: javascript password generator example 
Javascript :: javascript fetch api post 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =