I am using the following jquery but this does not seem to work. Can someone tell me where i am going wrong.

Đ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.

*

Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first)

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 input field has a class name formData use this :$(“.formData”).val(“data”)

If the input field has an id attribute name formData use this :$(“#formData”).val(“data”)

If the input name is given use this :$(“input“).val(“data”)

You can also mention the type. Then it will refer to all the inputs of that type and the given class name:$(“input.formData”).val(“data”)

*

This should work.

$(“.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

*

*

*

use this code for set value in input tag by another id.

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 set value in input tag using classname=”formdata”

$(“.formdata”).val(“hello”);
You just write this script. use input 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!

Please be sure to answer the question. Provide details and share your research!

But avoid

Asking for help, clarification, or responding to other answers.Making statements based on opinion; back them up with references or personal experience.

Xem thêm:

To learn more, see our tips on writing great answers.

Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged javascript jquery html or ask your own question.

Site design / logo © 2022 Stack Exchange Inc; user contributions licensed under cc by-sa. rev2022.4.19.41984

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.

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *