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 :: react, scroll element into view 
Javascript :: convert map to object/JSON javascript 
Javascript :: lodash pascal case 
Javascript :: nodejs format text 
Javascript :: sum of numbers array using for loop in javascript 
Javascript :: cypress have attribute 
Javascript :: array int to string javascript 
Javascript :: xhr post send 
Javascript :: javascript settimeout loop 
Javascript :: how to detect onend reach of scrollview in react native 
Javascript :: sum of n numbers in javascript 
Javascript :: javascript check if date object 
Javascript :: lodash remove undefined values from array 
Javascript :: code Execution time in nodejs 
Javascript :: javascript get a random array from 1 to n 
Javascript :: jquery search for string in text 
Javascript :: encodeuri hashtag 
Javascript :: letter javascript regex 
Javascript :: javascript go to div id 
Javascript :: how to send a message to a discord server using a bot 
Javascript :: nodejs check if express started 
Javascript :: neo4j create relationship between existing nodes 
Javascript :: unexpected token react native stack navigation 
Javascript :: convert hex code to rgb javascript 
Javascript :: how to find out which version of react 
Javascript :: reverse a date in javascript 
Javascript :: open a particular slide on click button in owl carousel 
Javascript :: object in array javascript 
Javascript :: js invert color 
Javascript :: if input value is null do something 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =