1

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.

1
  • <button id="mover" type="button" >Extend</button>. The id is mover not move here. Commented Dec 30, 2017 at 6:56

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.