I have a javascript script that changes an image's src when clicked. When I had the same application in pure php without Codeigniter I simply had the images' src be something like "images/image_name" where images was the images folder, but now I'm using Codeigniter I don't know how to do it. I can't use php inside the JS script obviously so can't use the base_url() or site_url() functions or anything, so I suppose only the absolute path would work. And my images are in an images folder that's inside an assets folder which is at the root (i.e. at the same level as the Application, System and User_guide folders). So what should the images' src be? Thanks.
You can use php code inside script.
<script>
var imgSrc="<?php echo base_url('assets/images/image_name.jpg'); ?>";
</script>
Or you can also declare a global variable in header file to store base path.
<script>
basePath='http://www.yourdomain.com/';
</script>
and it can be used as
var imgSrc=basePath+"assets/images/image_name.jpg";