Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize RadioButton,input,CheckBox value assignment in jQuery

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "how to achieve RadioButton,input,CheckBox value assignment in jQuery", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to achieve RadioButton,input,CheckBox value assignment in jQuery" this article.

1. 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 value of input

('# id'). Val ()

4. Jquery judgment checkbox checkbox

$("# id:checkbox") .attr ("checked")

Take a value of $("# id") .attr ("value")

The value is assigned directly in text () and val ().

How does JQUERY get text,areatext,radio,checkbox, select values?

("input") .val ()

("textarea") .text ()

("select") .val ()

Control form elements:

Text box, text area: $("# txt") .attr ("value",''); / / clear the content

$("# txt") .attr ("value", '11'); / / fill the content

Check box checkbox: $("# chk1") .attr ("checked",'); / / do not check

$("# chk2"). Attr ("checked", true); / / check

If ($("# chk1"). Attr ('checked') = = undefined) / / determine whether it has been checked

Select group radio: $("input [@ type=radio]") .attr ("checked",'2'); / / set the project of value=2 as the currently selected item

Drop-down box select: $("# sel") .attr ("value",'- sel3'); / / set the project of value=-sel3 as the currently selected item

$("11112222"). AppendTo ("# sel") / / add the option of the drop-down box

$("# sel"). Empty (); / / clear the drop-down box

JQuery gets and sets the value of the select drop-down box article classification: .net programming

Get Select:

Get the text selected by select:

$("# ddlRegType"). Find ("option:selected"). Text ()

Get the value selected by select:

("# ddlRegType") .val ()

Get the index selected by select:

$("# ddlRegType") .get (0) .selectedIndex

Set up the select:

Set the index selected by select:

$("# ddlRegType"). Get (0). SelectedIndex=index;//index is the index value

Set the value selected by select:

("# ddlRegType") .attr ("value", "Normal")

$("# ddlRegType") .val ("Normal")

$("# ddlRegType"). Get (0). Value = value

Set the text selected by select:

Var count=$ ("# ddlRegType option") .length

For (var iTuno Bandi)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report