Fill in a form with jQuery

后端 未结 9 1979
眼角桃花
眼角桃花 2020-12-31 03:04

I am trying to use jQuery to fill in a form with some default values.

The form is contained in a div which has an id. In fact every element has an id, I did so just t

相关标签:
9条回答
  • 2020-12-31 03:47

    You can use the val() function to set input values

    $("#coordX_0").val(123);  
    

    Incidentally, your original code could be made to work by setting value property on the actual, underlying dom element. You access the dom element by indexing your jQuery results:

    $("#coordX_0")[0].value = 123;  
    
    0 讨论(0)
  • 2020-12-31 03:49

    Just write:

    $("#coordX_0").val(123);
    

    In jQuery, text is a function to extract text in dom.

    0 讨论(0)
  • 2020-12-31 03:57
    $("#coordX_0").val("123");
    

    You need the quotes too I think. Although it might work both ways.

    0 讨论(0)
提交回复
热议问题