如何将此代码转换为j查询 [英] How to convert this code to j query

查看:101
本文介绍了如何将此代码转换为j查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<!DOCTYPE html>
<html>
<head>
<body>

<h1> Celcius to Fahrenhiet</h1>

<p>Insert a number into one of the input fields below:</p>

<p><input id="c" onchange="convert('C')"  onkeyup="convert('C')" type="number" > degrees Celsius</p>

<p><input id="f" onkeyup="convert('F')" type="number"> degrees Fahrenheit</p> 


<script>


function convert(degree)
 {
    var x;
    if (degree == "C") {
                          x = document.getElementById("c").value * 9 / 5 + 32;
                              document.getElementById("f").value = Math.round(x);
    }
   else if(degree == 'F'){

                      x = (document.getElementById("f").value -32) * 5 / 9;
                          document.getElementById("c").value = Math.round(x);
    }
}

</script>

</body>
</html>





我尝试过:



i已经尝试了$ sign和许多其他属性到函数字段但是它出错



What I have tried:

i have tried $ sign and many other attributes to the function field but it goes wrong

推荐答案

符号和许多其他属性到函数字段但出错了
sign and many other attributes to the function field but it goes wrong


document.getElementById("c") yo can replace this by

替换它

(# c)
如果使用getElementById使用点代替:
("#c") if you use getElementById use a dot instead like:


这篇关于如何将此代码转换为j查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆