Access to an inserted element
Hi Folks,
I'm new with jquery. I find, it's amazing but I run into a problem.
I insert an element into a website (between <div id=here></div>. It works.
This is an input field and a picture (a trashcan)).
Click on this picture shall delete the new content between the <div>s
This doesn't work.
Only on the content on bottom of the site (original content) works.
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="/static/global/js/jquery.js"></script>
</head>
<body>
<div id="vorlage" style="display : none" >
<p>
<input name="name" type="text" size="30" maxlength="40">
<img src="/static/global/bilder/trashcan.png" />
</p>
</div>
<button id="add">Add</button><br>
<div id="here"></div>
<p>
<input name="name" type="text" size="30" maxlength="40"><br><br>
<img src="/static/global/bilder/trashcan.png" />
<p>
<script>
$(function(){
$("#add").click(function()
{ var str = $("#vorlage").html();
$("#here").append(str);
}
);
$("img").click(function()
{ var img = $(this);
img.parents("p").remove();
});
});
</script>
</body>
I can not access thi new elements. It looks like it is not in DOM.
But firebug show the new elements in the DOM.
What goes wrong?
Thx for any hint
Timothy