Create an animation on the wordpress site

Asked

Viewed 66 times

0

I am creating an animation on the main wordpress page. To do this I am doing it as follows:

$(document).ready(function(){
   
   (function mover(i){
      
      $('#seta').animate({top: (i ? "-" : "+")+"100px"}, 1000, function(){
         mover(!i);
      });
      
   }())
   
});
#seta{
   position: relative;
}
.container img {
    max-width: 200px;
    max-height:250px;
    width: auto;
    height: auto;
}
.container {
    clear: both;
    margin-top: 20px;
}
img {
    vertical-align: top
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div id="seta" class="container">

<a href="http://xxxxxxxxx.xx/recrutamento/"><img src="http://xxxxxxxxxxx.xx/wp-content/uploads/small.png" width="320" height="205" /></a>
<h1>Procura Emprego! Clique aqui!</h1>
</div>

I’ve tested it and it works, but I’m not getting it to work on my site.

I show in the picture how I’m doing:

inserir a descrição da imagem aqui

But I get this error on the page as shown in the image:

inserir a descrição da imagem aqui

  • Yes you will receive an error even, by the print you sent Javascript is in the middle of tags p.

  • @Leandrade but without the tags, read the javascript code as if it were text, how can I solve?

1 answer

1


Your problem is simple, I just don’t know if you can solve it in a simple way.

When you place this script directly inside the WP text editor, the editor places a <p></p> to separate each line of text (can’t have that <p> within the script), because the editor doesn’t understand the text there as a script, even for security reasons.

inserir a descrição da imagem aqui

To try to fix this you can put your script directly in Footer, or Header, or even in the JS files folder of your theme. Here in this image gives you an idea, and these names and path of the folders can vary from theme to theme... The important thing is you know that by putting the <script> right inside the text editor will not work. try to put it in the header.php or footer.php

inserir a descrição da imagem aqui

In your case go to the menu tab to the left called Presentation, check the pasture and include the <script> in some .php or even .js checking which one would be ideal for it. But as I said it will vary from theme to theme these folders and names, but it usually puts itself in the footer or header

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.