“$ (ini) .data ()” Kode Jawaban

Atribut data jQuery

/* 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 mendapatkan atribut data

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


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

$ (ini) .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_

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya