0

I've added some jQuery code to my magento shop, to be able to make tabs ind my short desciption on my products. But it dont work.

My jQuery code

$(document).ready(function(){
  $(".contentMenuContent").css("display", "none");
  $(".contentMenuContent:first").show();

  $(".contentMenu").click(function() {

    $(".contentMenu").removeClass("contentMenuActive");
    $(this).addClass("contentMenuActive");

    var index = $(".contentMenu").index(this);

    $(".contentMenuContent:eq(" + index + ")").fadeOut("normal", function() {
    $(".contentMenuContent").css("display", "none");
    $(".contentMenuContent:eq(" + index + ")").fadeIn();
    });
  });
});

My short desciption

<table style="width: 100%;">
<tbody>
<tr>
<td style="text-align: center;" valign="top"><a class="contentMenu">Uddannelse 1</a></td>
<td style="text-align: center;" valign="top"><a class="contentMenu">Uddannelse 2</a></td>
<td style="text-align: center;" valign="top"><a class="contentMenu">Uddannelse 3</a></td>
</tr>
</tbody>
</table>
<div class="contentMenuContent">
<h4>Uddannelse 1 - Overskrift</h4>
HER INDS&AElig;TTER DU DIT INDHOLD <br /><br /></div>
<div class="contentMenuContent">
<h4>Uddannelse 2 - Overskrift</h4>
HER INDS&AElig;TTER DU DIT INDHOLD <br /><br /></div>
<div class="contentMenuContent">
<h4>Uddannelse 3 - Overskrift</h4>
HER INDS&AElig;TTER DU DIT INDHOLD <br /><br /></div>

My xml add - (I can se in my header that it is added)

<action method="addJs"><script>puk/contentmenu.js</script></action>
  • Check your inspect it's call frontend or not – Magento 2 Feb 5 '16 at 7:59
  • can you explain it a bit more? – Patrick Knudsen Feb 5 '16 at 8:01
  • Is there any errors in the console? Also what is your exact path to your contentmenu.js Also do you have jQuery Installed? – rob3000 Feb 5 '16 at 8:03
  • You know front end inspect element right? check there it show your script or not – Magento 2 Feb 5 '16 at 8:03
  • Åhh yeah. its there.@Kothari @rob3000 Path is /public_html/js/puk/contentmenu.js. And yeah its installed – Patrick Knudsen Feb 5 '16 at 8:08
0

Looking at your code, you are using $ as shortcut, which is usually owned by default JS library in Magento (prototype). Are you using noConflict() function, to avoid problems with Prototype?

https://learn.jquery.com/using-jquery-core/avoid-conflicts-other-libraries/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.