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 includes 
Javascript :: typescript read json file 
Javascript :: .split is not a function 
Javascript :: jquery set input value 
Javascript :: stomp.min.js cdn 
Javascript :: javascript copy image to clipboard 
Javascript :: how to generate random id in javascript 
Javascript :: react refresh 404 error 
Javascript :: javascript get class name 
Javascript :: sortby vue 
Javascript :: js Date(date).toLocaleString() MINUUTES 
Javascript :: js change value of every value in an object 
Javascript :: how to setup atom for javascript 
Javascript :: js check if is array 
Javascript :: how to filter nested array of objects in javascript 
Javascript :: allow only numbers and special characters in textbox using javascript 
Javascript :: sequelize findone 
Javascript :: downgrade node version windows using npm 
Javascript :: joi custom error 
Javascript :: kotlin jsonobject from string 
Javascript :: bootstrap 4 navbar-collapse not working angular 
Javascript :: download json file react 
Javascript :: jquery select self and siblings 
Javascript :: npm numeral 
Javascript :: particles js is not full screen 
Javascript :: add attribute in select option 
Javascript :: javascript timeout 
Javascript :: add formdata javascript 
Javascript :: smooth scroll safari 
Javascript :: first repeated character in a string javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =