admin管理员组文章数量:1405537
How do I convert this into 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
}
Thanks,
How do I convert this into 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
}
Thanks,
Share asked Jun 7, 2020 at 6:51 nabz123nabz123 131 silver badge3 bronze badges 3- 3 There is nothing you need to do. It already works. – Niet the Dark Absol Commented Jun 7, 2020 at 6:52
-
Change
document.getElementById("Username").value
to$("#Username").value
and same like all other ids. – Maniraj Murugan Commented Jun 7, 2020 at 6:55 - The jQuery is a JavaScript library, that is, it's an extension written in pure JS. So, you don't hsve to do anything, this will work if you use jQuery as well – FZs Commented Jun 7, 2020 at 7:12
1 Answer
Reset to default 4pure JS and Jquery can work together, your code always work with or without jquery, but if you want all codes in same format then.
function contantForm()
{
let Username = $("#Username").val();
let Emailinput = $("#Email").val();
alert("Thank you " + Username)
$("#Username").val("");
$("#Email").val("");
$("#Phone").val("");
}
<script src="https://cdnjs.cloudflare./ajax/libs/jquery/3.3.1/jquery.min.js"></script>
本文标签: How to convert JavaScript to JQueryStack Overflow
版权声明:本文标题:How to convert JavaScript to JQuery? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744918753a2632158.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论