Jquery codes dont work in Joomla, tried everything found on google -
i want wrap img span , set image span's background image can css trick image. found code
<script type="text/javascript"> $(document).ready(function(){ $("img").load(function() { $(this).wrap(function(){ return '<span class="image-wrap ' + $(this).attr('class') + '"'+'style="position:relative; display:inline-block; background:url(' + $(this).attr('src') + ') no-repeat center center; width: ' + $(this).width() + 'px; height: ' + $(this).height() + 'px;" />'; }); $(this).css("opacity","0"); }); }); </script>
and worked perfect in single html file. however, when added code ~/template/index.php, didn't work , browser reported:
uncaught typeerror: object # has no method 'ready'
it seemed jquery wasn't loaded, tried add following code index.php:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
and tried installing jquery easy plugin , enable it, none of them worked.
what wrong?
have here @ similar issue / solution:
joomla jquery not working, why that?
you can add jquery in templates -
<script type="text/javascript" src="<?php echo $this->baseurl ?>/templates/your_template_name/path_to_javascript_folder/your_jquery.js"></script> template - name of template path javascript folder - if folder present path of folder jquery.js - file name 1 want include.
Comments
Post a Comment