“$ (this) .data ()” Code-Antworten

JQuery Data Attribut

/* 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)
Potato

JQuery erhalten Datenattribut

<a data-id="123">link</a>


var id = $(this).data("id"); // Will set id to 123
Mingles444

$ (this) .data ()

1<div data-role="page" data-last-value="43" data-hidden="true" data-options='{"name":"John"}'></div>

JS
$( "div" ).data( "role" ) === "page";
$( "div" ).data( "lastValue" ) === 43;
$( "div" ).data( "hidden" ) === true;
$( "div" ).data( "options" ).name === "John";
mukashwasti_

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen