jQuery dynamically created table rows not responding to events

Posted by mithunmo on Stack Overflow See other posts from Stack Overflow or by mithunmo
Published on 2009-08-26T10:38:44Z Indexed on 2010/05/17 9:00 UTC
Read the original article Hit count: 270

Filed under:
|

I have a table with one row in my HTML file. Now in jQuery I append lot of rows based on the data in the database. But the anchor tag which is created dynamically doesn't respond to events. How do I make this anchor tag respond to events?

jQuery part

//Appending rows from the Database

$('<tr> <td> </td> <td id="log'+i+'"><a href="viewlog.php" target="_blank">log</a></td></tr> ').appendTo('#container');

Event part in jQuery Now when I write a line of code like this it does not respond.

$('#container a ').click(function()
{

    alert("Coming here ");
});

//HTML

<html>
    <table id="container">
        <tr>
            <td>
                Name
            </td>
            <td>
                Link
            </td>
        </tr>
    </table>
</html>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html