When I insert HTML snippet, header menu and sidebar menu are broken


JP Garza

I have a post on my WordPress site. Here I add the following code snippet:

<pre><code class="iframe-fragment"></code></pre>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> 
<script type="text/javascript">
  $('.iframe-fragment').load('https://roboticsys.com/support/plugins/servlet/docs/c1001-d1003/RapidCode/_absolute_motion_8cs-example.html div.fragment', function(res, status, xhr){
    $("a.code").each(function() {
      var $this = $(this);       
      var _href = $this.attr("href"); 
      $this.attr("href", 'https://roboticsys.com/support/plugins/servlet/docs/c1001-d1003/RapidCode/' + _href);
    });
 });
</script>

When I added this code snippet to my post, you can see it works perfectly and shows what it does. However, the main menu stops functioning, just like on the home page, and the sidebar menu can no longer be expanded.

Here is the post I'm working on : https://roboticsys.com/absolute-motion/

Any ideas?

life and death

1. Change the jQuery library to the latest (or newer) library to support $as follows:-

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 

2. Wrap your code $(document).ready(function(){..});like this:

<script type="text/javascript">
  $(document).ready(function(){
        $('.iframe-fragment').load('https://roboticsys.com/support/plugins/servlet/docs/c1001-d1003/RapidCode/_absolute_motion_8cs-example.html div.fragment', function(res, status, xhr){
        $("a.code").each(function() {
            var $this = $(this);       
            var _href = $this.attr("href"); 
            $this.attr("href", 'https://roboticsys.com/support/plugins/servlet/docs/c1001-d1003/RapidCode/' + _href);
        });
    });
  });
</script>

Note:- Try to check the browser console for any other errors related to jQuery (like conflicts due to using two different jQuery libraries etc.) and try to correct them

Related


Sidebar menu disappears when switching activities

Mohamad Mousheimish: I know this question is asked a lot, but none of the answers worked for me. I have two activities, MainActivityand ShopActivity. In MainActivityI have a sidebar menu. When I switch activities, the menu disappears and the problem happens. S

Fixed sidebar menu on left and fixed header on top

Pedro So what I want to do is a fixed sidebar with a fixed menu at the top and scrollable content in the middle. body, html { height: 100%; margin: 0; } aside { background: #90EE90; height: 100%; left: 0; position: fixed; top: 0; width: 120px;

Sidebar menu disappears when switching activities

Mohamad Mousheimish: I know this question is asked a lot, but none of the answers worked for me. I have two activities, MainActivityand ShopActivity. In MainActivityI have a sidebar menu. When I switch activities, the menu disappears and the problem happens. S

Fixed sidebar menu on left and fixed header on top

Pedro So what I want to do is a fixed sidebar with a fixed menu at the top and scrollable content in the middle. body, html { height: 100%; margin: 0; } aside { background: #90EE90; height: 100%; left: 0; position: fixed; top: 0; width: 120px;

Responsive sidebar push menu

innovation I have a question about responsive sidebar menu. First, I'll give you a demo from codepen.io If you change the width of the archer, you can see the green button in the upper right corner. When you click this button, the red background color div will

Responsive sidebar push menu

innovation I have a question about responsive sidebar menu. First, I'll give you a demo from codepen.io If you change the width of the archer, you can see the green button in the upper right corner. When you click this button, the red background color div will

HTML5 import with sidebar menu

Leo Odishvili I'm working on a project where I have very large sidebar menus for many pages, I really don't want to change it all the time on all pages, but I also don't want to use the php include() function. Well, I went and used the html5 import. It does wo

Sidebar menu triangle pointer appears when clicked

Roy Barn I created a simple sidebar nav menu here and you can see that - when linking - the rectangle/triangle remains.... Wondering how to fix this....? Why does it happen. This is how I get the pointer. ul.faq_questions li.active:after, ul.faq_questions li:h

Fixed sidebar menu on left and fixed header on top

Pedro So what I want to do is a fixed sidebar with a fixed menu at the top and scrollable content in the middle. body, html { height: 100%; margin: 0; } aside { background: #90EE90; height: 100%; left: 0; position: fixed; top: 0; width: 120px;

How do I fix my header menu changes when creating a new menu?

Jonathan Orie I want to create a submenu in a page that I can access from my header menu. I created the submenu, added a line to "register_nav_menus". I want the submenu's page to have the code for theme_location corresponding to the code added to "register_na

How do I fix my header menu changes when creating a new menu?

Jonathan Orie I want to create a submenu in a page that I can access from my header menu. I created the submenu, added a line to "register_nav_menus". I want the submenu's page to have the code for theme_location corresponding to the code added to "register_na

Fixed sidebar menu on left and fixed header on top

Pedro So what I want to do is a fixed sidebar with a fixed menu at the top and scrollable content in the middle. body, html { height: 100%; margin: 0; } aside { background: #90EE90; height: 100%; left: 0; position: fixed; top: 0; width: 120px;

HTML header menu dropdown not clickable

Guy Richards OK. I have a header designed in HTML - however, every time I hover over a product, and click the ANY submenu, I can't (they disappear before being clicked). A live example can be seen at http://www.bwl-ny.com . Any suggestions? Custom.js $(documen

How to insert logo in sidebar menu

Sima Mountain So I've been trying to create a horizontal menu with a logo at the top and a traditional navigation menu next to it. But I seem to be running into an issue where I can't put my logo in the horizontal menu and align it. Here is the code I am curre

The menu seems to be broken until I refresh the browser

lotus I've tried to put together a CODEPEN HERE for you , but I'm afraid it won't be of much help as I can't reproduce the problem here. This is a very complex and large website. It's very difficult to just give you the code that works for this, because there

Sidebar menu disappears when switching activities

Mohamad Mousheimish: I know this question is asked a lot, but none of the answers worked for me. I have two activities, MainActivityand ShopActivity. In MainActivityI have a sidebar menu. When I switch activities, the menu disappears and the problem happens. S

Close the sidebar menu when you click it or click on a menu item

Clara 83: The goal is to close the sidebar menu when I click on the sidebar menu or when I click on one of the menu items. I've created two working functions in Javascript to open and close the menu, click toggle: <script> function openNav() { document.getEl

html menu animation completely broken?

Nathan Pereira I'm trying to teach myself front-end development through online resources like w3schools.com and Code Academy, and I have the most basic knowledge of HTML and CSS. I started a little portfolio web project to test myself and see what I didn't kno

Fixed sidebar menu on left and fixed header on top

Pedro So what I want to do is a fixed sidebar with a fixed menu at the top and scrollable content in the middle. body, html { height: 100%; margin: 0; } aside { background: #90EE90; height: 100%; left: 0; position: fixed; top: 0; width: 120px;

HTML header menu dropdown not clickable

Guy Richards OK I have a header designed in HTML - however, every time I hover over a product, and click the ANY submenu, I can't (they disappear before being clicked). A live example can be seen at http://www.bwl-ny.com . Any suggestions? Custom.js $(document

The menu seems to be broken until I refresh the browser

lotus I've tried to put together a CODEPEN HERE for you , but I'm afraid it won't be of much help as I can't reproduce the problem here. This is a very complex and large website. It's very difficult to just give you the code that works for this, because there

The menu seems to be broken until I refresh the browser

lotus I've tried to put together a CODEPEN HERE for you , but I'm afraid it won't be of much help as I can't reproduce the problem here. This is a very complex and large website. It's very difficult to just give you the code that works for this, because there