N
N
Nohaga2020-04-27 10:55:06
JavaScript
Nohaga, 2020-04-27 10:55:06

How to add an attribute?

jQuery('video').attr("playsinline", "")
You need to add a playsinline attribute with no value to the video tag, so jQuery('video').attr("playsinline") doesn't. If with value then adds.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Sharomet, 2020-04-27
@sharomet

jQuery('video').attr("playsinline", "")

This way should work. Maybe your script is loaded first and then the video element?
Try adding a little delay to test this.
setTimeout(function() {
 jQuery('video').attr("playsinline", "");
}, 2000);

You can also try this
$('video')[0].setAttribute("playsinline","");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question