live : 현재 뿐만 아니라 앞으로 미래에 포함될 요소까지 자동으로 바인딩시킨다.
이벤트가 전체 도큐먼트 내에서 bubble up된다. die() 함수는 live() 함수에 의해서 생성된 이벤트를 제거한다.
live영역을 이용한 태그영역을 클릭하면 반응이 있다
예제
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <style type="text/css"> p{ background : yellow; padding: 5px; cursor: pointer; } </style> <script src = ../js/jquery.js type="text/javascript"></script> <script type="text/javascript"> $(function(){ var cnt = 0; $('p').live('dblclick', function(){ $(this).after('<p>Another paragraph ' + cnt++ + "</p>") if(cnt == 3){ $('p').die(); } }); });//ready </script> </head> <body> <p>Click me!</p> </body> </html>
결과
Click me!라는 버튼에 마우스를 올릴시 클릭할수 있게 마우스 모양이 변한다
'JQuery' 카테고리의 다른 글
[jQuery] show hide (0) | 2023.09.22 |
---|---|
[jQuery] change (0) | 2023.09.22 |
[jQuery] Bind (0) | 2023.09.21 |
[jQuery] 테이블 동적 생성 (0) | 2023.09.21 |
[jQuery] append (0) | 2023.09.21 |