1

How do I escape double qoutes. even try '\' but in console it look bad. that why its not working

var vimeo;

'      <span class="play-button button" data-vimeo-id="'+ vimeo +'" data-vimeo-iframe="<iframe src="https://player.vimeo.com/video/'+ vimeo +'?dnt=1&amp;app_id=122963" width="1920" height="1080" frameborder="0" title="bla bla" allow="autopla; fullscreen" allowfullscreen></iframe>" Play </span>'

Output

enter image description here

faisaljanjua
  • 886
  • 2
  • 13
  • 28

2 Answers2

0

You could use Typescript template strings, assuming the iframe string is just to retrieve at a later time (use decodeURIComponent):

var vimeo;
var iframe = encodeURIComponent('<iframe src="https://player.vimeo.com/video/' + vimeo + '?dnt=1&amp;app_id=122963" width="1920" height="1080" frameborder="0" title="bla bla" allow="autopla; fullscreen" allowfullscreen></iframe>');
var s = `<span class="play-button button" data-vimeo-id="${vimeo}" data-vimeo-iframe="${iframe}"> Play </span>`;
var element = document.createElement('div');
element.innerHTML = s;
document.body.append(element);
console.log(decodeURIComponent(document.getElementsByClassName('play-button')[0].getAttribute('data-vimeo-iframe')))
shrys
  • 5,860
  • 2
  • 21
  • 36
-1

Try this:

    var vimeo;

`<span class="play-button button" data-vimeo-id="${vimeo}" data-vimeo-iframe="<iframe src="https://player.vimeo.com/video/${vimeo}?dnt=1&amp;app_id=122963" width="1920" height="1080" frameborder="0" title="bla bla" allow="autopla; fullscreen" allowfullscreen></iframe>" Play </span>`
Burak
  • 44
  • 8