Home > Web Front-end > JS Tutorial > jQuery methods to get and set form elements_jquery

jQuery methods to get and set form elements_jquery

WBOY
Release: 2016-05-16 17:00:05
Original
977 people have browsed it

jQuery provides the val() method, using which we can quickly get and set the form's text box, radio button, and radio button value.
Using val() without parameters means getting the value of the element
Using val() with given parameters means assigning the value to the element

is as follows:

Copy the code The code is as follows:

//Get the value
alert($("input#mytextbox").val());
alert($("select#mylist").val( ));
alert($("input#myradio").val());

//Set value
$("input#mytextbox").val("61dh");
$("select#mylist").val("First column ");
$("input#myradio").val(2);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template