데이터 id 속성용 어떻게 다운로드합니까??

39 m, 유사 플러그인에는 사용하여 i& 포함한다. 내가 할 수 있는 항목을 클릭한 데이터 id 반드시 redhat. 웹 서비스.

어떻게 다운로드합니까 데이터 id 속성용? # 39, m ' ()' 방식을 사용하여 i& 오언 재 바인드 정렬할지 클릭 행사를 할 수 있습니다.

<! - begin 스니핏: js 숨기십시오: 거짓값 콘솔: 진정한 바벨. &gt 거짓값 -;

$("#list li").on('click', function() {
  //  ret = DetailsView.GetProject($(this).attr("#data-id"), OnComplete, OnTimeOut, OnError);
  alert($(this).attr("#data-id"));
});

,,, /script&gt &lt &gt &quot &quot &lt 스크립트입니다 src = https://code.jquery.com/jquery-3.3.1.slim.min.js

<ul id="list" class="grid">
  <li data-id="id-40" class="win">
    <a id="ctl00_cphBody_ListView1_ctrl0_SelectButton" class="project" href="#">
      <img src="themes/clean/images/win.jpg" class="project-image" alt="get data-id" />
    </a>
  </li>
</ul>

끝 - &lt 스니핏 >;!

질문에 대한 의견 (4)
해결책

컨텐트에서 데이터 id 얻기 위해 '속성' (주로 '&lt 데이터 id 123";;;; a = &quot &gt link&lt /a>') 사용할 수 있습니다.

$(this).attr("data-id") // will return the string "123"

또는 '.data ()' (jQuery 를 사용하는 경우, 새로운 &gt 1.4.3 =)

$(this).data("id") // will return the number 123
  • 및 부품 '' 후 '가 아니라', '데이터 이드 섬 데이터 소문자여야 합니다 작동하지 will.* 데이터 이드 섬' (예:
해설 (15)

우리가 원하는 경우 기존 넷윈을 , 또는 업데이트하려면 읽어들이려면 사용하여 이러한 속성 및 메서드 게타트리부트 스테트리부트 JavaScript 를 사용하여 다음과 같이, 그럼 우린 그렇게 할 수 있다

  • JavaScript 를 통해 *
<div id='strawberry-plant' data-fruit='12'></div>

<script>
// 'Getting' data-attributes using getAttribute
var plant = document.getElementById('strawberry-plant');
var fruitCount = plant.getAttribute('data-fruit'); // fruitCount = '12'

// 'Setting' data-attributes using setAttribute
plant.setAttribute('data-fruit','7'); // Pesky birds
</script>
    • 통해 jQuery
// Fetching data
var fruitCount = $(this).data('fruit');
OR 
// If you updated the value, you will need to use below code to fetch new value 
// otherwise above gives the old value which is intially set.
// And also above does not work in ***Firefox***, so use below code to fetch value
var fruitCount = $(this).attr('data-fruit');

// Assigning data
$(this).attr('data-fruit','7');

검토완료 이 문서를

해설 (0)

중요. , 특성 있는 점을 유념하십시오 조정할 경우 '' 데이터 무중단으로 javascript 를 통해 데이터 () 는 '이 반영되지 않습니다' 기능을 포함한다. '데이터 ()' 기능을 통해 이를 조정하십시오 합니다 잘 알려져 있다.

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

js:

$(this).data("id") // returns 123
$(this).attr("data-id", "321"); //change the attribute
$(this).data("id") // STILL returns 123!!!
$(this).data("id", "321")
$(this).data("id") // NOW we have 321
해설 (2)

기존 IE 브라우저에 대한 고민이 있지 않다면, HTML5 데이터세트를 apiu 을 사용할 수도 있습니다.

  • HTML *
<div id="my-div" data-info="some info here" data-other-info="more info here">My Awesome Div</div>
    • JS
var myDiv = document.querySelector('#my-div');

myDiv.dataset.info // "some info here"
myDiv.dataset.otherInfo // "more info here"

데모: http://html5demos.com/dataset

전체 브라우저 지원 목록: [http://caniuse.com/ # 성과 = 데이터세트를] [3]

[3]: http://caniuse.com/ # 성과 = 데이터세트를

해설 (1)

아무도 놀라게 한 것.


<select id="selectVehicle">
     Mazda
     Honda
     Mercedes
     Toyota
해설 (1)
  • HTML *
<span id="spanTest" data-value="50">test</span>
    • JS
$(this).data().value;

또는

$("span#spanTest").data().value;

&gt, ANS. 50

Works for me!

해설 (0)
var id = $(this).dataset.id

works for me!

해설 (0)

내가 달러 를 사용하는 .data - http://api.jquery.com/jquery.data/

//Set value 7 to data-id 
$.data(this, 'id', 7);

//Get value from data-id
alert( $(this).data("id") ); // => outputs 7
해설 (0)

'Id' 는 비트 데이터 액세스 색상에는 고유한 특성을 쉽게 for me.

$ (&quot, # Id") ',' .data (attribute&quot ";)

<! - begin 스니핏: js 숨기십시오: 거짓값 콘솔: 진정한 바벨. &gt 거짓값 -;

function myFunction(){
  alert($("#button1").data("sample-id"));
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

 Clickhere 

끝 - &lt 스니핏 >;!

해설 (0)

이 코드를 데이터 속성 값을 반환되므로 예: , 저는 표시됩니까 id 에 데이터 id 데이터 시간 데이터 이름 상술합니다.

<a href="#" id="click-demo" data-id="a1">Click</a>

js:

$(this).data("id");

// 내려받습니다 값을 &gt 데이터 id -; a1

$(this).data("id", "a2");

이렇게 하면, - &gt 데이터 id 변경하십시오 // a2

$(this).data("id");

// 내려받습니다 값을 &gt 데이터 id -; a2

해설 (0)

jquery 를 사용하여.

  $( ".myClass" ).load(function() {
    var myId = $(this).data("id");
    $('.myClass').attr('id', myId);
  });
해설 (0)

하는 사람들을 위해 동적으로 사용할 수 있습니다 '폐기' 와 '활성화하십시오 제거하고 재설정하려는 도구팁' 방법입니다. 참조 [https://getbootstrap.com/docs/4.0/components/tooltips/ # 토올팁디스포세] [1]

[1]: https://getbootstrap.com/docs/4.0/components/tooltips/ # 토올팁디스포세

해설 (0)