[英]Selecting text in a popup box using Jquery
我有一個按鈕。 當我單擊該按鈕時,會出現一個彈出 CSS 框,其中包含一個包含一些數據的文本字段。 我希望在彈出框打開后立即選擇此數據。 我嘗試在 jquery 中使用 .select() 函數,但它似乎不起作用。
這是按鈕:-
<div id="copyBox" style="display:inline-block; margin-left: 10px;">
<button class="btn copy-button" id="obj" data-clipboard-text="Take data from URL and put it here using Jquery" >
<a href="#openModal" style="color: #fff;">Copy URL</a>
</button>
</div>
這是彈出框:-
<div id="popup1" class="overlay">
<div class="popup">
<span class="poptext">Copy URL to share the link</span>
<a class="close" href="#">×</a>
<div class="content">
<input type="text" id="urlText" style="width:90%;">
</div>
</div>
</div>
這是我正在使用的 jquery:-
$( "#obj" ).click(function() {
$("#urltext").select();
});
我不知道我哪里出錯了。 任何人都可以幫我解決這個問題嗎?jquery
您在 jquery 中更改了 id 名稱。 更改urlText而不是urltext 。 它必須區分大小寫
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.