如何将J脚本转换为JQuery?

如何将其转换为 JQuery?


function contantForm()

{

    let Username = document.getElementById("Username").value;  //create element Id called Username

    let Emailinput = document.getElementById("Email").value; //create element Id called Emailinput

    alert("Thank you " + Username) //alerts user with thier username after clicking submit

    document.getElementById("Username").value=""; //get username Id from index page

    document.getElementById("Email").value=""; //get email Id from index page

    document.getElementById("Phone").value=""; //get phone Id from index page

}

谢谢


函数式编程
浏览 44回答 1
1回答

浮云间

纯JS和Jquery可以一起工作,你的代码总是使用或不使用jquery,但是如果你想要所有代码都采用相同的格式。function contantForm(){&nbsp; &nbsp; let Username = $("#Username").val();&nbsp;&nbsp;&nbsp; &nbsp; let Emailinput = $("#Email").val();&nbsp;&nbsp; &nbsp; alert("Thank you " + Username)&nbsp;&nbsp; &nbsp; $("#Username").val("");&nbsp;&nbsp; &nbsp; $("#Email").val("");&nbsp;&nbsp; &nbsp; $("#Phone").val("");&nbsp;}<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript