开发者

get id of div using jquery

<ItemTemplat开发者_如何转开发e>
<div class="list_row">
<div class="list_rowtext"  style="width: 16%; text-align: left; padding-left: 5px;"
<a href="#" id=<%# Eval("CourseId") %> class="delbutton">
<img  border="0" alt="Delete" />
</a>
<div>
<ItemTemplate>
I'm using below code to delete a row from listview.although row is deleted from db but not reflected in listvoew. actually i think  this code var tr_id =   $(this).closest(".list_row"); is not getting <div>.

$("a").click(function () {
        //Get the Id of the record to delete
        var record_id = $(this).attr("id");
        //Get the ListView Row reference
        var tr_id = $(this).closest(".list_row");
        alert(tr_id);
        // Ask user's confirmation before delete records
        if (confirm("Do you want to delete this record?")) {

            $.ajax({
                type: "POST",                 
                url: "DisplayCourses.aspx/DeleteCourses",
                data: "{'args': '" + record_id + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function () {
                    tr_id.css("background-color", "lightgreen");
                    tr_id.fadeOut(500, function () {
                        tr_id.remove();
                    });
                }
            });
        }
        return false;
    });


I've tried to piece that together...

$('.delbutton').click(function() {

   // Here is the id that you want.
   var id = $(this).closest('.list_rowtext').attr('id');

   // Something like this is what you probably want to do.
   $(this).closest('.list_row').slideUp(500, function() { $(this).remove(); });

});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜