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

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 :: js read from json2 
Javascript :: Putting password in a zip file using node.js 
Javascript :: click outside react component 
Javascript :: unload in jquery 
Javascript :: how to get file extension in javascript 
Javascript :: jquery scrollheight 
Javascript :: javascript find all odd between two numbers 
Javascript :: redirect users to anmother page in javascript 
Javascript :: btoa javascript 
Javascript :: js json stringfy beutify 
Javascript :: nice react native shadow 
Javascript :: luxon timestamp 
Javascript :: how to add background image in mui 
Javascript :: login page link shopify 
Javascript :: react-router-dom navlink active 
Javascript :: reverse a string without affecting special characters in javascript 
Javascript :: clear swr cache 
Javascript :: how to render a new page in node js through express 
Javascript :: jquery closert 
Javascript :: random string from array javascript 
Javascript :: Auto scroll to bottom of div angular 
Javascript :: find whitespace in string js 
Javascript :: json.stringify formatting 
Javascript :: javascript get image width and height 
Javascript :: what is the meanof using next in nodejs 
Javascript :: datepicker auto close 
Javascript :: convert decimal to binary javascript 
Javascript :: check if any property of object is null javascript 
Javascript :: how to use typeof in javascript 
Javascript :: angular {{}} new line 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =