In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to use the options collection in javascript". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use the options collection in javascript".
The object.options.add (new Option (label,value)) method adds an option object to the collection
The object.options.remove (index) method removes the specified item from the options collection
Object.options (index) or options.item (index) can get the specified items of the options collection through the index
The select tag also has an attribute of selectedIndex, which makes it possible to get the currently selected option index: object.selectedIndex
1. Clear the options collection
Code highlighting produced by Actipro CodeHighlighter (freeware)
Http://www.CodeHighlighter.com/
-& gtfunction optionsClear (object)
{
Var length = object.options.length
For (var iMUTHUTHUTHUTHI > = 0PUBILUR -) {
E.options.remove (I)
}
}
two。 Add a new option
Code highlighting produced by Actipro CodeHighlighter (freeware)
Http://www.CodeHighlighter.com/
-& gtfunction addOption (object)
{
Object.add (new Option (label,value))
/ / use the last item in the options collection to get focus
Object.selectedIndex = object.lentht-1
}
3. Delete an option specified in the options collection
Code highlighting produced by Actipro CodeHighlighter (freeware)
Http://www.CodeHighlighter.com/
-& gtfunction removeOption (index)
{
If (index > = 0)
{
Object.remove (index)
/ / use the last item in the options collection to get focus
Object.selectedIndex = object.lentht-1
}
}
4. Gets the real value value of the currently selected option
Code highlighting produced by Actipro CodeHighlighter (freeware)
Http://www.CodeHighlighter.com/
-& gtfunction getCurrentOptionValue (index)
{
If (index > = 0)
Return object (index). Value
}
5. Gets the display value label of the currently selected option
Code highlighting produced by Actipro CodeHighlighter (freeware)
Http://www.CodeHighlighter.com/
-& gtfunction getCurrentOptionLabel (index)
{
If (index > = 0)
Return object (index). Text
}
Thank you for your reading, the above is the content of "how to use the options collection in javascript". After the study of this article, I believe you have a deeper understanding of how to use the options collection in javascript, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.