Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
i want to insert image on page using javascript function
//JS $('#fff').html('<img src="../images/pic.jpeg">');
when i write the url as above ...nothing loaded.
How can i write correct URL ?
image_tag
/images/pic.jpg
$('#fff').html('<img src="../images/pic.jpeg">');
If the js code is in your view template, then you do do
$('#fff').html('<?php echo image_tag('pic.jpeg') ?>');
else if it is in a separate js file, you need to use the absolute path for it.
$('#fff').html('<img src="/images/pic.jpeg">');
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
image_tag/images/pic.jpg$('#fff').html('<img src="../images/pic.jpeg">');