I have 2 java script functions triggered by two separate buttons. I am trying to run this from within a django template. Button 1 works, but Button 2 does not. I am trying to make button 2 work. Any reason why button 2 doesn’t work? Or how to fix it?
<script type="text/javascript">
function addMore()
{
alert("Click!");
}
</script>
<script>
$('#add_more').click(function() {
alert('click');
});
</script>
<button onclick="addMore()">Button 1</button>
<input type="button" value="Button 2" id="add_more">
wrap the code in
$(document).ready()method. ex,the functions inside
.ready()method initializes when the whole document is ready.