Muhammad Bilal Khan
Muhammad Bilal Khan

Reputation: 21

JQuery undefined is not a function ASP.NET

i use jquery for calculation in grid all done well instead that when it is grand total turn jquery throw an error "Uncaught TypeError: undefined is not a function" at this line " $("[id*=txtTotal]").live("keyup", function () {", kindly give me suggestion.


Here is my code:

            function CalculateTotal(select) {

            var row = $(select).closest("tr");
            var ClPart = $("[id*=txtCl_Part]", row).val();
            //alert(ClPart.toString());
            var Assgnmnt = $("[id*=txtAssgnmnt]", row).val();
            //alert(Assgnmnt.toString());
            var Quiz = $("[id*=txtQuiz]", row).val();
            //alert(Quiz.toString());
            var WrPaper = $("[id*=txtWP]", row).val();
            //alert(WrPaper.toString());
            var OSME = $("[id*=txtOSME]", row).val();
            //alert(OSME.toString());
            var Total = (parseFloat(ClPart.valueOf()) + parseFloat(Assgnmnt.valueOf()) + parseFloat(Quiz.valueOf()) + parseFloat(WrPaper.valueOf()) + parseFloat(OSME.valueOf()));
            //   alert(Amount.toString());

            $("[id*=txtTotal]", row).val(Total.valueOf());
        }



        $("[id*=txtTotal]").live("keyup", function () {

           Error comes at above line


                var Gtot = 0;
                var percent = 0.0;
                $("[id*=txtTotal]").each(function (index) {
                    //Check if number is not empty
                    if ($.trim($(this).val()) != "")
                    //Check if number is a valid Float
                        if (!isNaN($(this).val()))
                            Gtot = Gtot + parseFloat($(this).val());
                    percent = (parseFloat(Gtot) * 100) / 400;
                });


                $("[id*=txtGTot]").val(Gtot.valueOf());
                $("[id*=txtPercent]").val(percent.valueOf());

            });

Upvotes: 0

Views: 190

Answers (3)

Muhammad Bilal Khan
Muhammad Bilal Khan

Reputation: 21

it finally works...

Joel it will something like this

$(documnet).on("event","selector", function() {} )

Upvotes: 0

juanechomon
juanechomon

Reputation: 91

//Let you handle an element even if it's not registered in DOM

$(document).on("keyup", "#<%=txtTotal.ClientID%>", function() {});

//Or do this

$("#<%=txtTotal.ClientID%>").keyup(function() {});

//Or this

$("#<%=txtTotal.ClientID%>").on("keyup",function() {});

Upvotes: 0

Joel
Joel

Reputation: 2257

Live was removed in jquery 1.9 per documentation (https://api.jquery.com/live/).

Instead, use the new "on" method

$("[id*=txtTotal]").on("keyup", function () {});

Upvotes: 2

Related Questions