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

Val how to set the value of a text box as a function as a parameter

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

Share

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

This article mainly shows you the ".val function as a parameter to set the value of the text box", the content is easy to understand, clear, hope to help you solve the doubt, the following let the editor lead you to study and learn ".val how to set the value of the text box as a parameter" this article.

Val (value)

.val (value) returns: jQuery

Description: sets the value of each element in the matching collection of elements.

Added version: 1.0.val (value)

Value

Type: String, Array

A text string or an array in the form of a string sets the value of each matching element.

Added version: 1.4.val (function (index, value))

Function (index, value)

Type: Function ()

A function that returns the set value. This points to the current element. The element in the received collection, with the old value as the index position of the parameter.

This method is typically used to set the value of a form field.

Pass an array of elements, allowing matches, and the ones in the are selected. For belonging to a radio button group, other elements will be unchecked.

The .val () method allows us to set this value through a function. Starting with jQuery 1.4, this function takes two parameters, the referenced value of the current element and its current value:

$('input:text.items') .val (function (index, value) {

Return value +''+ this.className

})

This example appends the string "items" to the text box.

Example:

Example: sets the value of the text box as an argument to the function.

Type something and then click or tab out of the input.

$('input'). Bind (' blur', function () {

$(this) .val (function (I, val) {

Return val.toUpperCase ()

});

});

These are all the contents of the article ".val how to set the value of a text box as a parameter". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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