0

I trying to give option to visitors of my website with two menus, which I activate by clicking on their gender ('Muži' link on toggle have to show the visitors menu for Mens and 'Ženy' link on toggle have to show the visitors menu for Womens)..

I getting in console this error: Uncaught SyntaxError: Unexpected token '<'

Here is my code snippet, problem is with that whole content (with styles) is in function woodstock_mega_menu_women() for example (if I save the content into variable it render without styles) but I tried to pass it into variable, because I working with jQuery actions (toggle,..) but it doesn't show variable on front-end and give error into Browser Console (I tried option with these characters: ", ', """, ''', and without them)

It's not a just variable, in this function which I have to echo is HTML content and the quotation marks in html content make it more complicated

The code snippet I sending here:

<a href="#" id="milano-one" class="milano-active milano-tlacitko">
    Muži
</a>
<a href="#" id="milano-two" class="milano-tlacitko">
    Ženy
</a>

<ul class="navigation menu tdl-navbar-nav mega_menu">
<script>
    jQuery('#milano-one').click(function(){
        jQuery('#milano-one').addClass('milano-active');
        if(jQuery('#milano-two').hasClass("milano-active")) {
                jQuery('#milano-two').removeClass('milano-active');
                var menu = <?php json_encode(woodstock_mega_menu_men()); ?>;
                document.write(menu)
        }
                                
    });
    jQuery('#milano-two').click(function(){
        jQuery('#milano-two').addClass('milano-active');
        if(jQuery('#milano-one').hasClass("milano-active")) {
            jQuery('#milano-one').removeClass('milano-active');
            var menu = <?php json_encode(woodstock_mega_menu_women()); ?>;
            document.write(menu)
        }

    });
    </script>
</ul>   
  • `var menu = = json_encode(woodstock_mega_menu_men()?>;` – miken32 Jul 13 '21 at 19:16
  • And you do understand that indentation in Javascript is purely cosmetic? Your `document.write()` statements are not conditional. – miken32 Jul 13 '21 at 19:17
  • @miken32 to make it clear.. condition is up and checking if the specific button has class `milano-active` and on this condition it should echo the specific function output – Martin Orešanský Jul 14 '21 at 07:09

0 Answers0