Search

Wednesday, September 30, 2015
0 comments

fire event inside another event using JQuery

2:25 AMWednesday, September 30, 2015
Introduction
In this article i will show you how to fire event inside event using JQuery. I will give an example of it. In this article, first we create a table using JQuery then append the table with the dynamically created table. First, we get the column of the table for inside event then generate function on table row. Lets check the example.

Source code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="browserdetails.aspx.cs" Inherits="browserdetails" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    <title></title>
    <script>
 

        $(function () {
            $("#btncreate").click(function () {
                var newtable = '<table id="mytable"><tr><td>Column1</td><td>Column2</td></tr><tr><td>Row11</td><td>Row12</td></tr></table>';
                $("#tbcontainer").append(newtable);

                var tblid = $("#tbcontainer table").attr("id");
           
                $("#" + tblid).on("click", "tr:last", function () {
                    var val1 = $(this).find("td").eq(0).text();
                    var val2 = $(this).find("td").eq(1).text();
                    alert(val1 + "  " + val2);
                })
            })
        })
</script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
    <label id="tbcontainer" />
   
        <input id="btncreate" type="button" value="button" />
    </div>
    </form>
</body>
</html>

Code Generate the following output
fire event inside another event using JQuery

Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top