【问题标题】:title does not work with decodeURIComponent and space标题不适用于 decodeURIComponent 和空格
【发布时间】:2015-03-14 23:16:40
【问题描述】:

我正在尝试使用 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/

我是一个绝对的新手,所以我非常感谢任何建议。另外我不是以英语为母语的人,所以我很抱歉我的英语不好......

【问题讨论】:

    标签: javascript title space decodeuricomponent


    【解决方案1】:

    decodeURIComponent(filename) 的输出包装在quotes 中。

    $(".intome").append(
        $('<img title="' + decodeURIComponent(filename) + '" src=' + dir + ' />')
    );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多