通过javascript中图片标签中的php变量传递图片网址 [英] Pass image url through php variable in image tag in javascript

查看:62
本文介绍了通过javascript中图片标签中的php变量传递图片网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想显示图片...此图片的网址存储在php变量中.现在我想在图像标记中使用此变量..我正在使用以下代码,但它不显示图像...请指导我如何通过javascript中图像标记中的php变量传递图像url ...

提前谢谢...

Hi,

I want to display image... the url of this image is stored in a php variable. Now i want to use this variable in image tag.. I am using following piece of code but it does not display image... Kindly guide me how i pass image url through php variable in image tag in javascript...

Thanks in advance...

element.html('<div class="data"> < img src=< ?php $imgPath="pages/image-0.png"; echo $imgPath; ?> height="500" width="440"></div>');




也尝试了以下代码,但输出仅显示双引号,分号,问号和制表符....如下所示

;?>

代码是:




following code is also tried but the output is just displaying double quote , semi-colon, question mark and angle braket.... as given below

"; ?>

the code is:

element.html('< div class="data">< ?php $imgUrl="pages/images-3.png"; echo "< img src=\"".$imgUrl."\" height=\"500\" width=\"440\">"; ?>< /div>');

推荐答案

imgPath ="pages/image-0.png"; echo
imgPath="pages/image-0.png"; echo


imgPath; ?> height ="500" width ="440"></div>');
imgPath; ?> height="500" width="440"></div>');




也尝试了以下代码,但输出仅显示双引号,分号,问号和制表符....如下所示

;?>

代码是:




following code is also tried but the output is just displaying double quote , semi-colon, question mark and angle braket.... as given below

"; ?>

the code is:

element.html('< div class="data">< ?php


imgUrl ="pages/images-3.png";回声< img src = \".
imgUrl="pages/images-3.png"; echo "< img src=\"".


这篇关于通过javascript中图片标签中的php变量传递图片网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆