Take the 2-minute tour ×

I required a function to remove URLs from <a> divs found within <div class="rj_insertcode">. Not being familiar with with direction to tackle this, I eventually mustered up the following Jquery code:

<script type="text/javascript">
    $('div.rj_insertcode a').each(function() {

My site uses Joomla CMS and I was able to add the above script to the bottom of the template index.php. It works quite well and removes the links generated between the defined tags.

My problem:
Pages that also include JavaScript do not operate correctly. JavaScript appears to be disabled or not functioning.

What can I change to ensure JavaScript still operates correctly, or is there another method I could adopt?

share|improve this question
there might be some other errors happening on the page due to your code which is breaking everything... –  kobe Dec 30 '10 at 3:30
Can you post an error from the javascript console? –  chaimp Dec 30 '10 at 3:31
what do you mean by "Javascript appears to be disabled or not functioning."? –  sheeks06 Dec 30 '10 at 3:32
add comment

4 Answers

up vote 7 down vote accepted

Have you tried using jQuery(... rather than $(... ? That would be a first place to start. I'm not too familiar with Joomla, but I know many CMS's will put jQuery into noConflict mode, and try to keep things happy with any other javascript libraries that might be included.

share|improve this answer
add comment

Joomla uses Mootools, which does not work with jQuery and would cause your script to break on pages that use Mootools. You can try:

    window.addEvent('domready', function(){
    $$('div.rj_insertcode a').set('href','');
share|improve this answer
It's discussed here, with some solutions: forum.joomla.org/viewtopic.php?t=283215 –  chaimp Dec 30 '10 at 3:34
This sounds quite likely Column. –  Graham Dec 30 '10 at 3:35
How would I incorporate this into my index.php file? I am not familiar with MooTools. –  Graham Dec 30 '10 at 3:42
The same as the jQuery. Just put it in the template. You would need to make sure Joomla loads mootools on all the pages, which might be a setting. Here is a good place to start (as I am sure that the code I provided wont do exactly what you wanted) mootools.net/docs/core/Element/Element –  Colum Dec 30 '10 at 4:18
Check this: docs.jquery.com/Using_jQuery_with_Other_Libraries –  Henrik Jan 9 '11 at 17:53
add comment

What is the actual problem? Javascript is not being loaded, not executing or not executing correctly? You could use Firebug to get more info and/or paste some page source as it's shown in the browser where the problem is.

share|improve this answer
add comment

Unlike most other modern CMS's such as Expression Engine, Drupal, or WordPress, Joomla loads MooTools in the Joomla head tag rather than jQuery. Using PHP to remove the MooTools can cause third party modules to break.

By default loading jQuery with MooTools causes the page to break. Use MooTools instead and you should be all set.

Cheers, Christopher

share|improve this answer
add comment

Your Answer


