0

I am trying to write with javasctipt line of code, but decodeURIComponent ignore everything after %20 (space). How to solve this?

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

Instead of:

<img title:"some text" src="img.png">

I am geting this:

<img title:"some" text src="img.png">

JSFiddle: https://jsfiddle.net/emnLy1t5/9/

I am an absolute newbie so I would really appreciate any advice. Also I am not native english speaker, so I am sorry for my bad english...

Matthias
  • 7,432
  • 6
  • 55
  • 88
MrJ
  • 13
  • 3

1 Answers1

0

Wrap the output of decodeURIComponent(filename) in quotes.

$(".intome").append(
    $('<img title="' + decodeURIComponent(filename) + '" src=' + dir + ' />')
);
Matthias
  • 7,432
  • 6
  • 55
  • 88