Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery到纯javascript的转换_Javascript_Jquery - Fatal编程技术网

jQuery到纯javascript的转换

jQuery到纯javascript的转换,javascript,jquery,Javascript,Jquery,由于我没有使用任何外部库,我想将以下fiddle转换为的非jQuery版本: 演示: 由于我没有使用任何外部库,为什么不使用呢?提示:使用vanilla JS、getElementsByTagName、loop、EventListener、.value、.disabled等。我正在设计一个非常简单的HTA应用程序,可以通过intranet而不是internet运行。尽量保持简单。jQuery确实保持简单,IMO。在这一点上,我支持Jason。只需在本地包含jQuery。非常感谢!非常感激它=)

由于我没有使用任何外部库,我想将以下fiddle转换为的非jQuery版本:

演示


由于我没有使用任何外部库,为什么不使用呢?提示:使用vanilla JS、getElementsByTagName、loop、EventListener、.value、.disabled等。我正在设计一个非常简单的HTA应用程序,可以通过intranet而不是internet运行。尽量保持简单。jQuery确实保持简单,IMO。在这一点上,我支持Jason。只需在本地包含jQuery。非常感谢!非常感激它=)
$(':text').keyup(function() {
    if($('#first_name').val() != "" && $('#second_name').val() != "") {
       $('#submit').removeAttr('disabled');
    } else {
       $('#submit').attr('disabled', true);   
    }
});
var first = document.getElementById('first_name'),
    second = document.getElementById('second_name'),
    submit = document.getElementById('submit');
first.onkeyup = second.onkeyup = function() {
    submit.disabled = !(first.value && second.value);
};