2017-10-07 3 views
0

Ich benutze eine asp.net-Webanwendung und ich habe ein Skript wie folgt.Jquery auf keyup wird nicht ausgelöst

<script> 
    $(document).ready(function() { 
    $("#popup input").keyup(function() { 
     var total = 0; 

     $(".txtLitAmount").each(function (index, item) { 

      temp = parseFloat($(item).val()); 

      if (isNaN(temp)) 
       temp = 0 
      total = total + temp; 
     }); 
     $("#lblTotal").text(total); 
    }); 
    }); 
</script> 

Html Teil als.

<div> 
 
<table width="100%" class="table"> 
 
     <thead> 
 
        <tr> 
 
         <th>Dimension Code</th> 
 
         <th>Dimension Name</th> 
 
         <th>Amount</th> 
 

 
        </tr> 
 
       </thead> 
 
       <tbody> 
 

 
      <tr class="gradeX"> 
 

 
       <td> 
 
        Dubai Office</td> 
 
       <td> 
 
        Sales</td> 
 
       <td> 
 
        <input type="text" value="0.00" id="litAmount_0" class="txtLitAmount"></td> 
 
      </tr> 
 

 

 
      <tr class="gradeX"> 
 

 
       <td> 
 
        Dubai Office</td> 
 
       <td> 
 
        Test</td> 
 
       <td> 
 
        <input name="litAmount" type="text" value="0.00" id="litAmount_1" class="txtLitAmount"></td> 
 
       
 
      </tr> 
 
      </tbody> 
 

 
     </table> 
 
     <div style="width: 100%; padding-left: 624px;"> 
 
     <label style="margin-right: 20px;">SubTotal</label> 
 
     <span id="lblTotal" class="lblSubtotal">0.00</span> 
 
    </div> 
 

 
</div>

Wenn ich das Skript auf Browser-Konsole ausführen, funktioniert es. Aber aus Anwendung, feuert es nicht das Key-up-Ereignis, wenn Typ Werte in den Textfeldern. Kann mir jemand helfen? Vielen Dank im Voraus.

+0

ich nur den Code gelesen haben, aber Sie haben keine Element/Container with'id = "Pop-up" ':/ –

Antwort

0

Ich habe Ihren Code überprüft ich denke, dass Sie meinen Schritt folgen können.

<script> 
$(document).ready(function() { 
$("input").keyup(function() { 
    var total = 0; 

    $(".txtLitAmount").each(function (index, item) { 

     temp = parseFloat($(item).val()); 

     if (isNaN(temp)) 
      temp = 0 
     total = total + temp; 
    }); 
    $("#lblTotal").text(total); 
}); 
}); 
+0

Nein. Es schießt nicht. – Vahid

0

Sind Sie sicher, dass Sie diese Zeile in Ihrem Code hinzugefügt haben?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
+0

Ja. Ich habe das hinzugefügt. – Vahid

0

Es läuft https://www.bootply.com/QlIZUYOKDu

Ich habe gerade $("#popup input") mit $(".txtLitAmount")

+0

Für mich funktioniert es nicht. Ich habe einen Breakpoint in der ersten Zeile hinzugefügt (_ $ ("input"). Keyup (function() _). Dann zum Zeitpunkt der Seite Ladekontrolle kommt zu Break-Point. Aber wenn Typ Werte auf Textfeld Steuerung ist nicht kommt zum Bruchpunkt Warum das passiert ?? – Vahid

+0

@Vahid irgendeine Fehlermeldung in der Konsole? (Rechtsklick irgendwo in Ihrem Web, wählen Sie "Inspect-Element", gehen Sie auf "Konsole" Registerkarte) –

Verwandte Themen