On Thu, Jul 11, 2013 at 6:25 PM, Madan U Sreenivasan <[email protected]> wrote:
> What you need is not 'calling', but 'embedding'  - you should be doing this:
>             $('#box4').css('background-image', 'url(images/<?php echo
> $filename; ?>)');

This isn't usually the recommended way to do it. It gets unmanageable
once you start working on bigger applications.

One way would be to use CSS classes, it is a good idea when you don't
have too many variables to handle. e.g. you have to alternate between
white and red backgrounds you can do try this
http://jsfiddle.net/3T2rJ/

This works when the choices are known beforehand and very limited. If
you need something dynamically generated using the server side script
you can try http://jsfiddle.net/eJX2W/
What this does it that it keeps the javascript part clean. You can
serve JS code from external file, which is good for performance
reasons.

PS: My JS skills are not too great so my code may not be optimum, if
so you're welcome to improve upon it.
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
ILUGC Mailing List Guidelines:
http://ilugc.in/mailinglist-guidelines

Reply via email to