사용자가 "a.open-popup"을 클릭하면 변경할 HTML (1 기능)과 팝업 (간단한 기능)이 필요합니다. 어떻게해야합니까? 나는 2 개의 함수 중 1 개만 트리거 할 수 있습니다.1 개의 선택기와 함께 2 개의 이벤트를 트리거하는 방법은 무엇입니까?
HTML :
<div>
<p class="plan-msg">Plan message</p>
<div class="completed-button">
<a href="#popup01" class="open-popup">Did it</a>
</div>
</div>
의 jQuery 함수 1 (HTML 변경)
jQuery('a.open-popup').click(function(event){
var $parent = jQuery(this).parent();
event.preventDefault();
$parent.siblings('.plan-msg').remove();
$parent.removeClass('completed-button')
.addClass('add-inv-button ')
.html('Add to Plan');
});
의 jQuery 함수 2 (오픈 simplelightbox)
$(function(){
jQuery("a.open-popup").click(function(event) {
event.preventDefault();
jQuery(this).simpleLightbox({ closeLink:'a.close' });
});
})
감사합니다.
이것은 작동하지 않는 것 같습니다. a.open-popup을 클릭하면 브라우저가 div # popup01을 열지 않습니다. 대신 www.mydomain.com/#popup01로 이동하면 화면이 비어 있습니다. – JMan
링크를 클릭하는 기본 동작이므로 페이지가 탐색 중입니다. 위와 같이 탐색을 방해하는 편집을했습니다. 문제가 해결되지 않으면 사용중인'simpleLightbox' 플러그인의 문서에 대한 링크를 게시하십시오. 그러면 더 도움이 될지 알 수 있습니다. – Lee
두 jQuery 함수 모두 event.preventDefault를 포함하도록 위 코드를 업데이트했습니다. 그러나 지금은 원래의 문제로 돌아 왔습니다. 2 개의 이벤트 중 하나만 트리거되지만 둘다는 트리거하지 않습니다. 다음은 simpleLightbox 코드에 대한 링크입니다. http://bit.ly/fp7FjY – JMan