I am using the following jquery but this does not seem lớn work. Can someone tell me where i am going wrong.
Bạn đang xem: Jquery setting value of input field
$(".formData").html("");Edited JQuery Function that handles the event
$("#reset").click(function () $("#userNameErr").text(""); $("#badgeNoErr").text(""); $(".errors").html(""); $(".formData").val(""); );nor is $(".formData").text("") or $(".formData").val("") working.
Help us improve our answers.
Are the answers below sorted in a way that puts the best answer at or near the top?
If the đầu vào field has an id attribute name formData use this :$("#formData").val("data")
If the input name is given use this :$("input
You can also mention the type. Then it will refer to lớn all the inputs of that type & the given class name:$("input
$(".formData").val("valuesgoeshere")For empty
$(".formData").val("")If this does not work, you should post a jsFiddle.
Demo:
$(function() $(".resetInput").on("click", function() $(".formData").val(""); );)Click Here to reset
Xem thêm: Những Bí Quyết Giao Tiếp Larry King, Đọc Sách Truyện Những Bí Quyết Giao Tiếp Tốt
$(".formdata").val(document.getElementById("fsd").innerHTML);oruse this code for phối value in đầu vào tag using classname="formdata"
$(".formdata").val("hello");
You just write this script. Use đầu vào element for this.
$("input").val("valuesgoeshere"); or by id="fsd" you write this code.
$("input").val(document.getElementById("fsd").innerHTML);
Thanks for contributing an answer to Stack Overflow!
But avoid …
Asking for help, clarification, or responding lớn other answers.Making statements based on opinion; back them up with references or personal experience.To learn more, see our tips on writing great answers.
By clicking “Post Your Answer”, you agree lớn our terms of service, privacy policy and cookie policy
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.