使用JQuery选择ID [英] Selection of id using JQuery

查看:64
本文介绍了使用JQuery选择ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,
我正在使用JQuery来访问HTML元素,但出现错误消息

Hello Friends,
I''m using JQuery to access HTML elements but getting an error saying

object: HTMLDivElement


我粘贴了我的javascript代码以供参考


I paste down my javascript code for our reference

<script type="text/javascript">
        
            $(document).ready(function() {
            try{
                $(''#imgComment'').click(function() {
                $(''#msg'').slideToggle("fast", "");
                    
                    $.ajax({
                        type: "Post",
                        url: "WIPCommentsNotification.aspx",
                        method: "getWIPComments",
                        data: "{}",
                        dataType: "msjson",
                        contentType: "application/json; charset=utf-8",
                        success: function(data) {
                            if (data != ''null'') {
                                //$(''#details'').append(outputDT(data.mydt));
                                $(outputDT(data.mydt)).appendTo(''#details'');
                            }
                        },
                        error: function(event, request, settings) {
                            alert(msg);
                        }
                    });
                })
                $(''#closebutton'').click(function() {
                    $(''#msg'').fadeOut(''slow'');
                })
            }
                catch (e) {
                    alert(''An error has occurred: '' + e.message);
                }   
                
            });
        }
    </script>



和身体部位



And body part

<body topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
    <form id="form1"  runat="server">
    <div id="test"></div>
    <%--For floating div begin--%>
    <div style="height:110%;width:100%">
        <div id="floating-div">
            <img id="imgComment" src="Images/comment.jpg" style="height:50px;CURSOR:pointer;"/>
        </div>
    </div>
    <%--For floating div end--%>
    
    <%--For floating modal begin--%>
    <div id="msg">
        <div id="modal">
            <div class="modaltop">
                <div class="modaltitle">WIP Comments</div>
                <span id="closebutton" style="CURSOR:pointer;">
                    <img alt="Hide Popup" src="Images/close_vista.gif" border="0" />
                </span>
            </div>
            <hr />
            <div id="details" class="modalbody">
               WIP Comments
            </div>
        </div>    
    </div>
    <%--For floating modal begin--%>
    </form>
</body>



我可以知道以下行吗?



May I know the following line

$(outputDT(data.mydt)).appendTo(''#details'');


选择正确的div.

在此先感谢


selects the correct div.

Thanks in advance

推荐答案

(document).ready(function(){ 试试{
(document).ready(function() { try{


(``#imgComment'').click(function(){
(''#imgComment'').click(function() {


(``#msg'').slideToggle( "fast",");
(''#msg'').slideToggle("fast", "");


这篇关于使用JQuery选择ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆