tailieunhanh - JavaScript Bible, Gold Edition part 77

JavaScript Bible, Gold Edition part 77. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | 608 Part III Document Objects Reference About this object OPTION elements are nested inside SELECT elements. Each option represents an item in the list of choices presented by the SELECT element. Properties of the OPTION element object let scripts inspect whether a particular option is currently selected or is the default selection. Other properties enable you to get or set the hidden value associated with the option as well as the visible text. For more details about the interaction between the SELECT and OPTION element objects see the discussion about the SELECT object earlier in this chapter as well as the discussion of the properties and methods associated with the options array returned by the SELECT object s options property. I discuss all backward-compatible OPTION object properties defaultSelected selected text and value among the options property descriptions in the SELECT object section. The only items listed in this section are those that are unique to the OPTION element object defined in newer browsers. In NN3 and IE4 there is a provision for creating a new option object via an Option object constructor function. The syntax is as follows var newOption new Option text value Here text is the string that is displayed for the item in the list and value is the string assigned to the value property of the new option. This new option object is not added to a SELECT object until you assign it to a slot in the options array of the SELECT object. You can see an example of this approach to modifying options in Listing 26-1. Properties label Value String Read Write NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 Compatibility The label property corresponds to the HTML LABEL attribute of an OPTION element. This attribute and property enables you to assign alternate text for an option. The property is implemented in IE5 Mac and NN6. In IE5 Mac any string assigned to the LABEL attribute or corresponding property overrides the display of text found between the start .

TỪ KHÓA LIÊN QUAN