아래 코드에서 html()안에 있는 function(index, html)의 매개변수 index와 html의 인자값을 어디서 보내주는건가요? 자바에서는 보통 함수 호출시 function(인자, 인자); 이렇게 호출해야 하는데 아래 자바스크립트 코드에서는 function(index,html)을 호출하는 코드가 보이지 않아서 여쭤봅니다 ``` $(document).ready(function(){ $('h1').bind('click',function(){ $(this).html(function(index, html){ console.log(index); return html + '+'; }); }); }); ```
# jQuery 내부적으로 호출 되는 듯 합니다. 저도 의아해서 찾아보니, jQuery 내부적으로 호출한다고 하는군요. html() API를 읽다보면, 아래와 같은 설명이 있습니다. Type: Function( Integer index, htmlString oldhtml ) => htmlString A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set. ## 참조링크 --- - https://api.jquery.com/html/