这一行
jq("#description" + tourId).html('<b>Opis: </b> '+ data);
在 IE、Firefox 和 Opera 中运行良好。
但是这个
jq("#images" + tourId).html('<img src=\"img\\gbflag.png\"/>');
仅适用于 IE。 Firefox 和 Opera 不显示图像。你知道为什么吗?
这是我的其余代码:
<script type="text/javascript">
var jq = jQuery.noConflict();
function showImages(tourId) {
jq(function() {
jq.post("/TourWebSpring/tourImages.html",
{tourId: tourId},
function(data) {
...
...
jq("#images" + tourId).html('<img src=\"img\\gbflag.png\"/>');
});
});
}
function showDetails(tourId) {
jq(function() {
jq.post("/TourWebSpring/tourDetail.html",
{tourId: tourId},
function(data) {
...
jq("#description" + tourId).html('<b>Opis: </b> '+ data);
});
});
}
最佳答案
我认为问题可能是您在 img
目录后使用了错误的斜杠,而且我认为您不需要转义双引号,因为您是用单引号定义字符串.尝试:
jq("#images" + tourId).html('<img src="img/gbflag.png"/>');
关于javascript - jQuery .html ('<img>' ) 在 FF 和 Opera 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11922082/