2

That question is generic.

I can't understand because when i include a bit of javacript code, only for testing something in magento, the following error returns:

Uncaught TypeError: Cannot read property

Anyone could give me an exemple of how a testing code should be?

This is the code I tested:

$("a").removeAttr("href");

2 Answers 2

2

Magento use prototype.js framework. So if you want to use jQuery to read an element.

Use jQuery instead of $

jQuery('a').removeAttr('href');
2
  • That's right I tested it and it worked perfect. Thank You Very Much Jul 8, 2015 at 19:17
  • For me, if i move attribute to attribute set i am getting error like snag.gy/Nmgn6p.jpg can u help me to get out this error?
    – Gem
    Oct 22, 2018 at 6:24
1

Your issue is probably because $ is calling prototype and you are trying to access a property of a jQuery object. You should use a jQuery.noConflict() to prevent this kind of issues in the future. There are several guides to achieve this with different approaches, use the one you are more comfortable with.

1
  • Thanks a lot I'll find out more about what you said Jul 8, 2015 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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