Javascript in posts
-
Hello.
I have a website where I inserted some scripts I made, on the front page it works just fine, I loaded in <head> </head> this:
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>and then I pasted my script where I wanted, it works fine.
When I want to add the same script intro posts, with text editor, nothing happens.
This is my script:
[ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]
<p> <img src="" /> <img src="" /> </p> <p id="demo" > text at loading page </p> <br> <!-- FADESCRIPT START --> <script> $('.c1').click(function(){ $('#demo').fadeOut(0).fadeTo( "fast", 0.01 ).fadeTo( "fast", 0.05 ).fadeTo( "fast", 0.09 ).fadeTo( "fast", 1 ).html('text1'); }) $('.c2').click(function(){ $('#demo').fadeOut(0).fadeTo( "fast", 0.01 ).fadeTo( "fast", 0.05 ).fadeTo( "fast", 0.09 ).fadeTo( "fast", 1 ).html('text2'); }) </script> <!-- FADESCRIPT STOP -->It’s just a script that changes the same paragraph with a different text when you click on the image with the same class as the one from function. I am not an expert with jquery and I don’t know how to make this work in posts. Also if there is any other form so that script be written to minify, please tell me.
I tried the solutions from Codex as well as some plugins (Javascrip in posts, Advanced Custom Fields) with no result.
The topic ‘Javascript in posts’ is closed to new replies.