0

Here in Sample DEMO i want to fire event when ever class .drow1 .subval lost focus, might be am missing something,

JS:

$(".drow1 .sub_val").on('blur',funtion(){
alert("hello");
});

Html:

<table border="1">
    <tr>
        <th>Col 1</th>
        <th>Col 2</th>
        <th>Type</th>
    </tr>
    <tr>
        <td> one</td>
        <td>
            <input type="text" value="600" class="sub_val" />
        </td>
        <td>dummy text</td>
    </tr>

    <tr class="drow1">
        <td> Two</td>
        <td>
            <input type="text" value="50" class="sub_val" />
        </td>
        <td>drow1</td>
    </tr>

    <tr class="drow1">
        <td> Three</td>
        <td>
            <input type="text" value="30" class="sub_val" />
        </td>
        <td>drow1</td>
    </tr>
     <tr class="drow2">
        <td> Four</td>
        <td>
            <input type="text" value="30" class="sub_val" />
        </td>
        <td>drow 2</td>
    </tr>
</table>

Edited: table row having class .drow1 is created dynamically, so its not getting fire

Satinder singh
  • 10,100
  • 16
  • 60
  • 102

1 Answers1

6

There is a typo in your code, funtion should be function:

$(".drow1 .sub_val").on('blur',function(){
   alert("hello");
});

Edit: If you are creating the elements dynamically, you should delegate the event:

$("table").on("blur", ".sub_val", function() {
    alert("hello");
});
Ram
  • 143,282
  • 16
  • 168
  • 197
  • @Satindersingh Well, actually typo is a common issue, checking the console is not a bad idea :) – Ram Oct 09 '13 at 08:15
  • It works on jsfiddle, as in my page am creating it dynamically, there it is not fire – Satinder singh Oct 09 '13 at 08:15
  • @Satindersingh [read this](http://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-element). – Vucko Oct 09 '13 at 08:27