How to make the text in the web page selected by default? The kind that can be copied directly by right-clicking.
Please ask the master for advice. . . . . . . . . . .
Try this code
<div class="nhtMsgText">
<input type="text" value="MSC10" readonly class ="msg_cord">
<input type="button" value="Copy">
</div>
$(".nhtMsgText input[type='button']").click(
function () {
$('input.msg_cord').focus(); //Select Object
$('input.msg_cord').select(); //Select object
document.execCommand("Copy"); //Execute browser copy command
})
Do you want to implement this function on your website? Directly add a button click event and use document.execCommand
Try this code
<div class="nhtMsgText">
<input type="text" value="MSC10" readonly class ="msg_cord">
<input type="button" value="Copy">
</div>
$(".nhtMsgText input[type='button']").click(
function () {
$('input.msg_cord').focus(); //Select Object
$('input.msg_cord').select(); //Select object
document.execCommand("Copy"); //Execute browser copy command
})
Do you want to implement this function on your website? Directly add a button click event and use document.execCommand