


RadioButton, input, CheckBox value assignment implementation code in jQuery
Jun 06, 2017 pm 04:15 PM1. jquery gets the radio group radio
$("input[name='name']:checked").val();
2. jquery gets the next value of radiobutton
$("input[name='name']:checked").next().text()$("input[name='name']:checked").val()
3. jquery gets the input value
$('#id').val()
4. jquery determines the checkbox
$("#id:checkbox").attr("checked") 取值 $("#id").attr("value");
Assignment is to give the value directly in text(), val()
How does JQUERY get the text, areatext, radio, checkbox, and select values?
$("input").val(); $("textarea").text(); $("select").val();
Control form elements:
Text box, text area: $("#txt").attr("value",'');//Clear content
$("#txt").attr("value",'11');//Fill content
Multiple selection box checkbox: $("#chk1").attr("checked",'' );//Unchecked
$("#chk2").attr("checked",true);//Checked
if($("#chk1").attr('checked') ==undefined) //Judge whether
radio group radio has been checked: $("input[@type=radio]").attr("checked",'2');//Set value The item =2 is the currently selected item
drop-down box select: $("#sel").attr("value",'-sel3');//Set the item value=-sel3 as the currently selected item Item
$("
jQuery Gets and sets the value of the select drop-down box Article Category:.net Programming
Get Select:
Get select selected text:
$("#ddlRegType").find("option:selected").text();
Get the value selected by select:
$("#ddlRegType ").val();
Get the index selected by select:
$("#ddlRegType ").get(0).selectedIndex;
Set select:
Set select selected index:
$("#ddlRegType ").get(0).selectedIndex=index;//index为索引值
Set select selected value:
$("#ddlRegType ").attr("value","Normal“); $("#ddlRegType ").val("Normal"); $("#ddlRegType ").get(0).value = value;
Set select selected text:
var count=$("#ddlRegType option").length; for(var i=0;i<count;i++) { if($("#ddlRegType ").get(0).options[i].text == text) { $("#ddlRegType ").get(0).options[i].selected = true; break; } } $("#select_id option[text='jQuery']").attr("selected", true);
Set select option item:
$("#select_id").append("
Clear Select:
$("#ddlRegType ").empty();

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Detailed explanation of jQuery reference methods: Quick start guide

How to use PUT request method in jQuery?

Disable or enable automatic copy selection for copying in Terminal

How to remove the height attribute of an element with jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page

Use jQuery to modify the text content of all a tags

Understand the role and application scenarios of eq in jQuery

Summary of commonly used file operation functions in PHP
