dont detect new element prepend by jquery
Hi, im starting with jquery and im trying to prepend a li to my ul list
- $.ajax({
- type: "POST",
- url: "gethtml.php",
- cache: false,
- data:
- {
- id : $('#input_id').val()
- },
- success: function(html){
- $("ul#list").prepend(html);
- $("ul#list li").show();
- },
- error:function(XMLHttpRequest,textStatus,errorThrown)
- {
- alert(textStatus);
- }
- });
- this html would be like ... <li><a href="#" id="1">Link</a></li>
- then i wil try to do this function when click on this links
- $("a").click(function(){
- alert( $(this).attr('id') );
- });
- if i load the page and i click on thoses default <li><a href="#" id="1">Link</a></li> works but if prepend with jqueryi click the new li <li><a href="#" id="2">Link 2</a></li> doesnt works until i refresh the page.
- Thanks!