Copy
<div style="float:right;"> <input type="text" id="buy_count_0" value="1"class="simpleform" onkeyup="함수.countBuy('keyup',this)" onblur="함수.countBuy('blur',this)"> <div> <a style="display:block" onclick="함수.countBuy('up',this)"><img src="/template/shop/images/arrow_up.gif"></a> // countBuy 함수 동작을 위해 클릭한다! </div> <span>개 <span class="option_price"><span id="price_item">{=number_format(goods.price_sell)}</span>원</span></span></div> <script type="text/javascript">countBuy = fucntion(mode , this){ var li = $(this).closest('li'); // 여기서 나오는 제이쿼리 closest 뜻을 알고 싶습니다. var input = li.find('input'); var cnt = input.val(); }</script>
onclick을 하게되면 자바스크립트 countBuy함수에서 this을 받아올텐데요
그런데 여기서 제이쿼리 closest을 이용해요 li태그 이것을 찾는 의미 인가요?
찾더라도 받아온 this는 a태그밖에 못가져올텐데요...
왜 li라고 적혀져 있는지 모르겠습니다 ㅠ,ㅠ
제이쿼리 closest 역활을 알기 쉽게 알고 싶네요 ㅠ,ㅠ 인터넷 뒤져봐도 이해가 안되서 이렇게
글로 문의 드립니다.
부탁드립니다 ㅠ,ㅠ
답변 1개
BlueAngel
9년 전
closest 는 $(this)의 상위요소중 가장 근접한 걸 반환하는걸로 알고있습니다.
답변을 작성하려면 로그인이 필요합니다.