Echoing jQuery in my functions.php file breaks some functionality
-
Hello to all,
So let me preface everything by saying ‘amateur/novice level developer here’.
I added a child theme as is standard practices. One of the things I am trying to do is add some jQuery to apply to certain elements (quote a few actually) in certain plugins.
When I add
echo" ";
and start putting in the jQuery, certain functionality breaks.truncated code here:
echo " <script src='https://code.jquery.com/jquery-latest.js' type='text/javascript' /></script> <script src='https://code.jquery.com/ui/1.10.3/jquery-ui.js' type='text/javascript' /></script> <script type='text/javascript'> $( document ).ready(function() { var someVariable = $('.element').width(); var otherVariable = $('.otherElement').width(); $('.element1 , .element2').css({'margin-left':'25px'}); $('.element3').css({'background':'rgba(0,0,0,0.1)'}); }); </script> ";
Noticed issue 1): When customizing, after any changes made the ‘save & publish’ button does not changed to saved. Then upon closing, I get the standard “are you sure you want to leave this page” warning, implying the changes I made did not get saved – but they are.
Noticed issue 2) I cannot see the media files any longer. In the admin side, it just keeps thinking over and over without any result.
I should say that the jQuery does appear that it is being rendered/executed correctly.
I have read somewhere at sometime that writing in straight jQuery can cause hiccups, if so then can you help find where the best place would be to insert custom jQuery?
Thanks in advance!
- The topic ‘Echoing jQuery in my functions.php file breaks some functionality’ is closed to new replies.