Home > Web Front-end > JS Tutorial > jquery text,radio,checkbox,select operation implementation code_jquery

jquery text,radio,checkbox,select operation implementation code_jquery

WBOY
Release: 2016-05-16 18:50:27
Original
906 people have browsed it

Control form elements:

Text box, text area:
$("#txt").attr("value") or $("#txt").val()//Get the value
$("#txt").attr("value",'');//Clear the content
$("#txt").attr("value",'11');//Fill the content

Multiple selection box checkbox:
$("#checkbox_id").attr("value") or $("#checkbox_id").val();//Get the value
$( "#chk1").attr("checked",'');//Unchecked
$("#chk2").attr("checked",true);//Checked
if( $("#chk1").attr('checked')) //Determine whether the

radio group radio has been checked:
$("input[type=radio][checked]") .val();//Get the value
$("input[name=tt]").attr("checked",'value2');//Set the item with value='value2' as the currently selected item
$("input[name=items]").get(1).checked = true;//The second element is the currently selected value

drop-down box select:
$("select [name=topSearch] option[selected]").val();//Get the value
$("select[name=topSearch] option[selected]").text();//Get the display content
$("#sel").attr("value",'sel3');//Set the item with value='sel3' as the currently selected item
$("").appendTo("#sel")//Add the option of the drop-down box
$("#sel").empty();//Clear the drop-down box
$('#select_id' )[0].selectedIndex = 1;//The second element of the drop-down box is the currently selected value

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