문제

저는 twitter-bootstrap3에서 작업하고 있습니다. "mybtn" 버튼을 클릭하면 id="myModal"인 모달이 팝업되고 "mybtn2" 버튼을 클릭하면 id="myModal2"인 모달이 팝업됩니다.그런데 두 버튼 중 하나를 클릭하면 두 버튼이 모두 팝업됩니다. 어떻게 해야 하나요?

로그인/업

<button id="mybtn2"  style="display:none;" 
    class="btn btn-primary btn-lg" href="#signup" data-toggle="modal" data-target=".bs-modal-sm">
      Sign In/Up
  </button>

<div class="modal fade bs-modal-sm" id="myModal"  tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-sm" >
//code
</div></div>

<div class="modal fade bs-modal-sm" id="myModal2"  tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-sm" >
//code
</div></div>
도움이 되었습니까?

해결책

타겟팅하려는 모달의 ID를 추가하세요.지금 당장 당신의 data-target 속성은 클래스를 가리키고 있습니다. bs-modal-sm 두 모달 모두에 적용됩니다.노력하다 data-target="#myModal" 또는 data-target="#myModal2" 적절한.

다음은 bootply 데모입니다: 링크

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top