我正在尝试使用javasctipt代码行编写,但是decodeURIComponent忽略了%20(空格)之后的所有内容。如何解决这个问题?
$(".intome").append($('<img title=' + decodeURIComponent(filename) + ' src=' + dir + ' />'));
而不是:
<img title:"some text" src="img.png">
我得到这个:
<img title:"some" text src="img.png">
JSFiddle: https://jsfiddle.net/emnLy1t5/9/
我绝对是一个新手,所以我真的很感激任何建议。另外,我的母语不是英语,所以我很抱歉我的英语不好......
将
decodeURIComponent(filename)
的输出括在引号中。
$(".intome").append(
$('<img title="' + decodeURIComponent(filename) + '" src=' + dir + ' />')
);