2012-06-28 1 views
0

이 질문은 매우 기본적인 것이지만 JQuery를 처음 사용하고 솔루션을 연습 할 수 없습니다.클로우즈 이미지를 클릭하면 jquery에 체크 박스 값을 가져옵니다.

이미지 인 클로져 버튼, 즉 'x'버튼을 클릭하면 모달 윈도우에서 체크 박스 값을 가져 오려고합니다.

도움을 주시면 감사하겠습니다. 감사합니다 .. 나는 $ 후 코드를 다음 추가 된

(문서) .ready (함수(), 아래

$('img#closeImg').on('click', function(){ 
alert($('.popupContact input[type=checkbox]').val()); 

<div id="popupScreen"> 
    <div id="popupContact"> 
    <form name="ReportParametersForm" name="ProcessActionForm" action="<portlet:actionURL> 
      <portlet:param name='generateReportAction' value='generateReportAction'/> 
      </portlet:actionURL>" method="post" onSubmit="return sendUserFeedback(doNotAsk)"> 
     <img src="<%= renderRequest.getContextPath() %>/NavigationClose.gif" id="closeImg" align="right" onclick="disablePopup()"> 
     <br/> 
     <p id="contactArea"> 
      To help us improve our intranet pages, can you please tell us in about 12 words, what you are accessing this area of the intranet for? 
      <br/><br/> 

      <table> 
      <tr> 
      <td><input type="text" name="userInput" id="userInput" size="60" onfocus="this.value='';" value="I am trying to find..."/></td> 
      <td><input type="submit" name="submitFeedback" value="Send feedback"> </td> 
      </tr> 
      </table> 
      <br/><input type="checkbox" name="doNotAsk" class=""> Please do not ask me for this feedback again 
      </form> 
    </div> 
    <div id="thankYou"> 
    <img src="<%= renderRequest.getContextPath() %>/NavigationClose.gif" align="right" onclick="disableNow()"> 
    <form name="closingForm" name="closingForm"> 
      <h5>Thank you for providing feedback to help us improve Exchange</h5> 
      <br/> 
      <br/> 
      <input type="button" name="Close" value="Close" onClick="disableNow()"> 
      </form> 
    </div> 
    <div id="backgroundPopup"></div> 
    <div id="mask"></div> 
    </div> 

답변

1
$('img#x').on('click', function(){ 
    alert($('.modal input[type=checkbox]').first().val()); 
}); 
  • 가 이벤트를 연결합니다 HTML 코드를입니다 x의 이미지 요소에
  • 클릭하면 처리기가 th e 값을 modal이라는 클래스와 함께 HTML 안에 넣습니다.
+0

안녕하세요 잰더는 빠른 답장을 보내 주셔서 감사합니다 ...하지만 위의 코드를 사용하면 모달 창을 로캘로 변환 할 수 없습니다. 왜 그런지, 어떤 작업을해야합니까? – user1127172

+0

안녕하세요 @ user1127172, 내가 문제의 전체 repro를 제공하지 않고 전혀 모르겠다 ... – xandercoded

+0

페이지의이 모달 창 onload로드 오전 ... 그래서 위의 코드를 $ (document) .ready 직후에 넣을 때 (function()) 모달 윈도우를 전혀로드하지 않습니다. – user1127172

관련 문제