To add the jquery, plus my own file (main.js
), I pasted this piece of code in my local.xml
:
<block type="core/text" name="google.cdn.jquery">
<action method="setText">
<text><![CDATA[<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><script>window.jQuery||document.write('<script src="/path/to/your/jquery.js">\x3c/script>');</script><script>jQuery.noConflict();</script>]]></text>
</action>
</block>
<action method="addItem">
<type>skin_js</type>
<name>js/main.js</name>
</action>
Seems alright, but when I use this function in my main.js
file, it doesn't do anything. Not even a console error:
$j('.block-title').click(function(){
alert();
});
I know this will probably be marked as a duplicate, but all the answers I've found don't seem to work. I have tried changing the classname, but that also did not work.
UPDATE
So I found out jQuery does work, with this:
var $j=jQuery.noConflict();
But there is still a problem.
$j(document).click();
Works fine, but when I call a class, like this:
$j('.footer').click()
It does nothing. I checked the classname alot, and even changed a few times to test. Didn't work. Is it possible, that jQuery 1.10.2 uses another form of calling classes?
LAST UPDATE:
Seems I had forgotten to place the .click function within the $j(document).ready() function... stupid me
$
instead of$j
? Or directlyjQuery
?