Reputation: 119
I am working with the following three files:
index.php
menu.php
move.js
menu.php
//...........................
<button id="mover" type="button" >Extend</button>
<script type="text/javascript" src="js/move.js"></script>
//........................
move.js
$("#move").click(function(){
console.log("move");
$("#container").animate({left: '5000px'}, "slow");
});
index.php
//............
<figure>
<?php include ("menu.php"); ?>
</figure>
<script type="text/javascript" src="js/move.js"></script>
//.............
My issue is that every time I click the "Extend" button (in menu.php), the event listener won't respond and it doesn't print to the console.
PS: I am new to php,and I am not sure if this is the right way to nest php files.
Upvotes: 1
Views: 57
Reputation: 30739
You have to change the name of the button id
from mover
to move
and then your javascript will work.
REPLACE
<button id="mover" type="button" >Extend</button>
<script type="text/javascript" src="js/move.js"></script>
WITH
<button id="move" type="button" >Extend</button>
<script type="text/javascript" src="js/move.js"></script>
Upvotes: 1