Answer the question
In order to leave comments, you need to log in
Why is text not being copied in IOS?
I implement the functionality of copying text on the click of a button. Everything works in Chrome on PC but does not work in the mobile version of IOS Safari
What's the problem?
<script type="text/javascript">
function copyToClipboard(element) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val($(element).text()).select();
document.execCommand("copy");
$temp.remove();
}
</script>
<p id="p1">Текст, который надо скопировать</p>
<button class="button--extra" onclick="copyToClipboard('#p1'); document.getElementsByClassName('copied')[0].style.display = 'block';">Скопировать отзыв в буфер</button>
<p style="display: none; text-align: center; margin: 0;" class="copied">Скопировано</p>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question