单击关闭图像时,在jquery中获取复选框值

时间:2012-06-28 01:27:18

标签: jquery jquery-ui

我知道这个问题非常基础,但我是JQuery的新手并且无法解决问题。

我想在单击cloase按钮即“x”按钮时从模态窗口中获取复选框值。

感谢任何帮助。感谢..

我在$(document).ready(function(),

之后添加了以下代码
$('img#closeImg').on('click', function(){
alert($('.popupContact input[type=checkbox]').val());

以下是html代码

 <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 个答案:

答案 0 :(得分:1)

$('img#x').on('click', function(){
    alert($('.modal input[type=checkbox]').first().val());
});
  • 将事件附加到ID为x的图像元素。
  • 单击时,处理程序会使用名为modal的类警告HTML内部的复选框的值。