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 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 :: eslint-disable-next-line 
Javascript :: javascript remove all spaces 
Javascript :: indexOf by object key 
Javascript :: javascript integer to string 
Javascript :: js detect link in string 
Javascript :: convert decimal to binary javascript 
Javascript :: activeclassname in react router v6 
Javascript :: react native load function each time visit screen 
Javascript :: how to set background colour i js inline stylel 
Javascript :: jquery growl cdn 
Javascript :: random rgba color javascript except black 
Javascript :: onchange js 
Javascript :: sotre json on chrome storage 
Javascript :: remove a object name from spread operator 
Javascript :: lodash remove element from list 
Javascript :: javascript check if string contains character 
Javascript :: javascript get closest element by class 
Javascript :: install node on ubuntu and debian 
Javascript :: How do I redirect to another webpage 
Javascript :: for loop value index react 
Javascript :: jquery on change 
Javascript :: javascript read server file 
Javascript :: sort object dictionary javscript 
Javascript :: how to define state in react function 
Javascript :: electron jquery 
Javascript :: get last item in array javascript 
Javascript :: contenteditable paste plain text 
Javascript :: javascript array of zeros 
Javascript :: node array 
Javascript :: change innertext javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =