Function triggering problem. It won't even alert!
Help I'm stuck!!
I'm using Jquery in Wordpress.
I want to add items and remove items from a page.
I'm adding ok.
But the remove function (detailed beside each element added
at runtime) is not being triggered. For simplicity I'd like to get it to 'alert' first.
Summary: Why won't any combination of function call work from these elements created at run-time? Anyone familiar with this? Please help!
-
<script type="text/javascript">
jQuery(document).ready(function ($) {
//addFeed();
$("#addFeed").click(function () {
addFeed();//works!
});
$(".sayHi").click(function () {
alert('hi');
});
function addFeed(){
if (input_id < 10)
{
$('#theValue').val(parseInt($('#theValue').val()) + 1);
//alert($('#theValue').val());
input_id = $('#theValue').val();
//limit to 5
$("#myDiv").append('<p id="feed'+input_id+'">Feed Name etc... <a href="#" class="sayHi">Say Hi</a><!-- this button doesn't work at all - no errors shown --> </p>');
return false;
}
}
});
</script>
.... some html ....
<p><a href="#" id="addFeed">Add a Feed</a></p> <!-- this button works -->
