2013-12-16 1 views
0

대신이 같은 루프를 작성에서 각 요소의 HTML을 설정? 같은 뭔가 :는 속성

$s.find("td.value").html($(this).attr("data-value")); 

답변

1

당신은 새로운 HTML을 반환 할 function argument of the html()를 사용할 수 있습니다. 그러나 jquery가 내부적으로 항목을 반복하므로 큰 차이는 없습니다.

$s.find("td.value").html(function(){ //Has 2 arguments second one will be the current html representation of the element and first argument the index of the item in the collection 
    return $(this).data("value"); 
});