将javascript代码转换为jquery(需要帮助)

时间:2020-12-29 02:05:16

I know this is simple. I'm trying to convert this code to jquery for better execution purposes. But I'm not sure about the syntax.

我知道这很简单。我正在尝试将此代码转换为jquery以实现更好的执行目的。但我不确定语法。

function CopyNotes() {
    var DataSet = document.getElementByID('checkid').value; 
    window.clipboardData.setData("TEXT", DataSet);
}

2 个解决方案

#1


0  

You can only convert the value reading of your function to jQuery (what is still javascript):

您只能将函数的值读取转换为jQuery(仍然是javascript):

function CopyNotes() {
    var DataSet = $('#checkid').val();
    window.clipboardData.setData("TEXT", DataSet);
}

#2


0  

Got it!

$("#copy-button").click(function() {
    var DataSet = $('#checkid').val();
    window.clipboardData.setData("TEXT", DataSet);
});

#1


0  

You can only convert the value reading of your function to jQuery (what is still javascript):

您只能将函数的值读取转换为jQuery(仍然是javascript):

function CopyNotes() {
    var DataSet = $('#checkid').val();
    window.clipboardData.setData("TEXT", DataSet);
}

#2


0  

Got it!

$("#copy-button").click(function() {
    var DataSet = $('#checkid').val();
    window.clipboardData.setData("TEXT", DataSet);
});