I am generating HTML elements using javascript. I applied the same class to all elements. I have a function that will execute when that class experiences the keyup event.
The problem is that my function is not recognizing the elements that javascript created.
See the example here --> jsFiddle
HTML
<p>Type in the box below, an alert will appear</p>
<input type='text' id='x' size='30' class='conv'/>
<br/><br/>
<button id='btn'>Now Click Me</button><br/><br/>
<div id='mainform'></div>
jQuery
$(document).ready(function() {
$('button').click(function() {
var a = "<p>The boxes below have the same class, thus they should show the alert when you type</p><input type='text' size='30' class='conv' id='a0'/><br/>";
var b = "<input type='text' size='30' class='conv' id='a1'/><br/>";
$('#mainform').append(a + b);
});
$('.conv').keyup(function() {
alert('it works');
});
});