0

我知道这个问题很基础,但我是 JQuery 新手,无法解决这个问题。

当单击关闭按钮(即作为图像的“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>
4

1 回答 1

1
$('img#x').on('click', function(){
    alert($('.modal input[type=checkbox]').first().val());
});
  • 将事件附加到 id 的图像元素x
  • 单击时,处理程序会警告一段 HTML 中的复选框的值,其中包含一个名为 的类modal
于 2012-06-28T01:31:49.763 回答