aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/mozilla/tech/xul/menuitem/index.html
blob: a231f6a34870bf15552b0ff0af02e471ac74dcd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
---
title: menuitem
slug: Mozilla/Tech/XUL/menuitem
tags:
  - XUL Elements
  - XUL Reference
translation_of: Archive/Mozilla/XUL/menuitem
---
<div class="noinclude">
 <span class="breadcrumbs XULRef_breadcrumbs">
 « <a href="/zh-CN/docs/XUL_Reference">XUL Reference home</a>    [
 <a href="#Examples">示例</a> |
 <a href="#Attributes">属性</a> |
 <a href="#Properties">特性</a> |
 <a href="#Methods">方法</a> |
 <a href="#Related">相关</a> ]
</span></div>
<p>A single choice in a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code> element. It acts much like a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/button" title="button">button</a></code> but it is rendered on a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code>.</p>
<p>More information is available in the <a href="cn/XUL_Tutorial/Simple_Menu_Bars">XUL tutorial</a>.</p>
<dl>
 <dt>
  Attributes</dt>
 <dd>
  <a href="#a-acceltext">acceltext</a>, <a href="#a-accesskey">accesskey</a>, <a href="#a-allowevents">allowevents</a>, <a href="#a-autocheck">autocheck</a>, <a href="#a-checked">checked</a>, <a href="#a-command">command</a>, <a href="#a-crop">crop</a>, <a href="#a-description">description</a>, <a href="#a-disabled">disabled</a>, <a href="#a-image">image</a>, <a href="#a-menuitem.key">key</a>, <a href="#a-label">label</a>, <a href="#a-menuitem.name">name</a>, <a href="#a-selected">selected</a>, <a href="#a-tabindex">tabindex</a>, <a href="#a-menuitem.type">type</a>, <a href="#a-validate">validate</a>, <a href="#a-value">value</a></dd>
</dl>
<dl>
 <dt>
  Properties</dt>
 <dd>
  <a href="#p-accessibleType">accessibleType</a>, <a href="#p-accessKey">accessKey</a>, <a href="#p-command">command</a>, <a href="#p-menuitem.control">control</a>, <a href="#p-crop">crop</a>, <a href="#p-disabled">disabled</a>, <a href="#p-image">image</a>, <a href="#p-label">label</a>, <a href="#p-labelElement">labelElement</a>, <a href="#p-parentContainer">parentContainer</a>, <a href="#p-selected">selected</a>, <a href="#p-tabIndex">tabIndex</a>, <a href="#p-value">value</a></dd>
</dl>
<dl>
 <dt>
  Style classes</dt>
 <dd>
  <a href="#s-menuitem-iconic">menuitem-iconic</a>, <a href="#s-menuitem-non-iconic">menuitem-non-iconic</a></dd>
</dl>
<h3 id="Example" name="Example">Example</h3>
<pre>&lt;menu id="edit-menu" label="Edit"&gt;
  &lt;menupopup id="edit-popup"&gt;
     &lt;menuitem label="Undo"/&gt;
     &lt;menuitem label="Redo"/&gt;
  &lt;/menupopup&gt;
&lt;/menu&gt;
</pre>
<h3 id="Attributes" name="Attributes">Attributes</h3>
<p> </p><div id="a-acceltext">

<dl>
 <dt>
  <code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code></dt>
 <dd>
  Type:
  <i>
   string</i>
 </dd>
 <dd>
  Text that appears beside beside the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> label to indicate the shortcut key (accelerator key) to use to invoke the command. If this value is set, it overrides an assigned key set in the key attribute. This attribute does not apply to menus directly on the menubar.</dd>
</dl>

<p></p>
</div> <div id="a-accesskey">




<dl>
 <dt><code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code></dt>
 <dd>类型:
 <i>character【字符】</i>
 </dd>
 <dd>本属性允许为控件(元素)设定一个字符作为快捷键,这个字符应该是 <code><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></code> 属性文本中的一个字符。该字符将会被加下划线以重点强调,平台和主体的变换并不影响这一表现行为。 当用户点击 ALT (在其他平台上具有类似功能的键) 和这个字符对应的按键时, 控件(元素)将立刻被从窗口中的某处激活或/并且获得焦点 <b>。虽说字符不分大小写,但是当label中存在大写字符和小写字符时,快捷键的字符将首先选择与之完全匹配的那一个,如果label中存在两个或更多的与accesskey字符相同的字符,其中的第一个字符将被加下划线。</b></dd>
 <dt>      *(有些键在监听按键事件时,分别对应event.ctrlKey和event.metaKey。)</dt>
</dl>

<p> </p>

<h4 id="Example" name="Example">Example</h4>

<div class="float-right"><img alt="Image:XUL_ref_accesskey_attr.png"></div>

<pre>&lt;vbox&gt;
  &lt;label value="Enter Name" accesskey="e" control="myName"/&gt;
  &lt;textbox id="myName"/&gt;
  &lt;button label="Cancel" accesskey="n"/&gt;
  &lt;button label="Ok" accesskey="O"/&gt;
&lt;/vbox&gt;
</pre>

<h4 id="See_also" name="See_also">See also</h4>

<p><code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute, <code id="a-acceltext"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/acceltext">acceltext</a></code> attribute</p>

<p></p>
</div> <div id="a-allowevents">


<dl>
 <dt><code id="a-allowevents"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/allowevents">allowevents</a></code></dt>
 <dd>Type:
 <i>boolean<br>
 </i>
 类型:boolean</dd>
 <dd>If true, events are passed to children of the element. Otherwise, events are passed to the element only.<br>
 如果为真,事件向子元素传递。否则,事件只传递到当前元素。</dd>
</dl>



<p></p>
</div> <div id="a-autocheck">


<dl>
 <dt><code id="a-autocheck"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/autocheck">autocheck</a></code></dt>
 <dd>类型:
 <i>boolean</i>
 </dd>
 <dd>如果此属性为 <code>true</code>,或空白, 每次点击按钮时,此按钮的状态检查都会被执行一次。如果此属性为<code>false</code>, 检查会手动的被拒绝。当autocheck值为true的时候,按钮将会变为多选框或者单选框。</dd>
</dl>



<p></p>
</div> <div id="a-checked">

<dl>
 <dt>
  <code id="a-checked"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code></dt>
 <dd>
  Type:
  <i>
   boolean</i>
 </dd>
 <dd>
  Indicates whether the element is checked or not.</dd>
 <dd>
  Use <code>hasAttribute()</code> to determine whether this attribute is set instead of <code>getAttribute()</code>.</dd>
 <dd>
  For buttons, the <code>type</code> attribute must be set to <code>checkbox</code> or <code>radio</code> for this attribute to have any effect.&lt;magic name="\"PAGENAME\"/"&gt;&lt;/magic&gt;</dd>
</dl>
</div><p></p>
<div class="note">
 <b>Note:</b> if the <code id="a-checked"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code> attribute is set to <code>true</code>, and you persist its value via the <code id="a-persist"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/persist">persist</a></code> attribute, Mozilla will fail to persist its value when the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> is unchecked because of <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=15232" title="persist should be able to remove an attribute from an element">bug 15232</a>. A workaround is to set the <code id="a-autocheck"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/autocheck">autocheck</a></code> attribute to <code>false</code>, then programmatically set the <code id="a-checked"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code> attribute when the user selects the item, and set it to <code>false</code> instead of removing the attribute (i.e. do <code>menuitem.setAttribute("checked", "false")</code> instead of <code>menuitem.removeAttribute("checked"))</code> when the user unchecks the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>, as a value of <code>false</code> will both correctly hide the checkmark and persist its hidden state.</div>
<p></p><div id="a-command">

<dl>
 <dt>
  <code id="a-command"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/command">command</a></code></dt>
 <dd>
  Type:
  <i>
   element id</i>
 </dd>
 <dd>
  Set to the <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> of a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/command" title="command">command</a></code> element that is being observed by the element.</dd>
</dl>

<p></p>
</div> <div id="a-crop">

<dl>
 <dt>
  <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code></dt>
 <dd>
  Type:
  <i>
   one of the values below</i>
 </dd>
 <dd>
  If the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the <code>crop</code> attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.</dd>
</dl>
<ul>
 <li><code>start</code>: The text will be cropped on its left side.</li>
 <li><code>end</code>: The text will be cropped on its right side.</li>
 <li><code>left</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its left side.</li>
 <li><code>right</code>: <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> The text will be cropped on its right side.</li>
 <li><code>center</code>: The text will be cropped in the middle, showing both the start and end of the text normally.</li>
 <li><code>none</code>: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.</li>
</ul>

<p></p>
</div> <div id="a-description">

<dl>
 <dt>
  <code id="a-description"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/description">description</a></code></dt>
 <dd>
  Type:
  <i>
   string</i>
 </dd>
 <dd>
  Descriptive text to appear in addition to the dialog title.</dd>
</dl>

<p></p>
</div> <div id="a-disabled">


<dl>
 <dt><code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code></dt>
 <dd> </dd>
 <dd>
 <h5 id="类型boolean">类型:<em>boolean</em></h5>
 </dd>
 <dd>
 <h5 id="表示元素是被禁用的。">表示元素是被禁用的。</h5>

 <p>如果这个元素的disabled属性被设置为true,表示元素被禁用,被禁用的属性在页面上通常会显示灰色文本,它无法响应用户的操作,它也无法得到光标。</p>

 <p>然而,这个元素仍然能够响应鼠标事件,如果要启用这个元素,把disabled设置为false</p>
 </dd>
</dl>

<h4 id="示例:">示例:</h4>

<div class="float-right"><img alt="Image:XUL_ref_attr_disabled.png" src="https://mdn.mozillademos.org/files/1742/XUL_ref_attr_disabled.png"></div>

<pre><code>// Disabling an element
document.getElementById('buttonRemove').setAttribute("disabled", "true");

// Enabling back an element by removing the "disabled" attribute
document.getElementById('buttonRemove').removeAttribute("disabled");</code></pre>

<p></p><div class="blockIndicator standardNote">
    <p><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/3.5">Firefox 3.5 note</a></p>
    <p style="font-weight: 400;">For <a href="https://developer.mozilla.org/en-US/docs/XUL/keyset" title="en/XUL/Keyset"><code>keyset</code></a> elements, support for this attribute was added in Firefox 3.5.</p>
</div><p></p>
</div> <div id="a-image">

<dl>
 <dt>
  <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code></dt>
 <dd>
  Type:
  <i>
   image URL</i>
 </dd>
 <dd>
  The URL of the image to appear on the element. If this attribute is empty or left out, no image appears. The position of the image is determined by the <code id="a-dir"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/dir">dir</a></code> and <code id="a-orient"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/orient">orient</a></code> attributes.</dd>
</dl>

<p></p>
</div> <div id="a-menuitem.key">

<dl>
 <dt>
  <code id="a-menuitem.key"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/menuitem.key">key</a></code></dt>
 <dd>
  Type:
  <i>
   element id</i>
 </dd>
 <dd>
  Set to the <code id="a-id"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/id">id</a></code> of a <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/key" title="key">key</a></code> element whose key shortcut is displayed in the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>.</dd>
</dl>

<p></p>
</div> <div id="a-label">

<dl>
 <dt>
  <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code></dt>
 <dd>
  Type: <em>string</em></dd>
 <dd>
  The label that will appear on the element. If this is left out, no text appears.<br>
  label 在元素上显示。如果左侧出界,则不显示任何文字。</dd>
</dl>

<p></p>
</div> <div id="a-menuitem.name">

<dl>
 <dt>
  <code id="a-menuitem.name"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/menuitem.name">name</a></code></dt>
 <dd>
  Type:
  <i>
   string name</i>
 </dd>
 <dd>
  Radio <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>s with the same name as put into a group. Only one <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> in each radio group can be checked at a time.</dd>
</dl>

<p></p>
</div> <div id="a-selected">

<dl>
 <dt>
  <code id="a-selected"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/selected">selected</a></code></dt>
 <dd>
  Type:
  <i>
   boolean</i>
 </dd>
 <dd>
  Indicates whether the element is selected or not. This value is read-only. To change the selection, set either the <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedIndex">selectedIndex</a></span></code> or <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selectedItem">selectedItem</a></span></code> property of the containing element.</dd>
</dl>

<p></p>
</div> <div id="a-tabindex">


<dl>
 <dt><code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code></dt>
 <dd>Type:<em>integer</em></dd>
 <dd>当用户按下 "<kbd>tab</kbd>" 键时焦点移动到元素上的顺序。<code>tabindex</code> 数字越大,顺序越靠后。</dd>
</dl>



<p></p>
</div> <div id="a-menuitem.type">

<dl>
 <dt>
  <code id="a-menuitem.type"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/menuitem.type">type</a></code></dt>
 <dd>
  Type:
  <i>
   one of the values below</i>
 </dd>
 <dd>
  Can be used to create checkable menuitems or for radio button menuitems.</dd>
</dl>
<ul>
 <li><code>checkbox</code>: The <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> is checked. The <code id="a-checked"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/checked">checked</a></code> attribute determines whether the menuitem is checked or not.</li>
 <li><code>radio</code>: The <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code> becomes part of a radio group. Other menuitems that have the same value for their <code id="a-name"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/name">name</a></code> attributes are part of the same <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/radio" title="radio">radio</a></code> group. Only one menuitem in the same radio group can be checked at once.</li>
</ul>
<p>More information on adding checkmarks to menus in the <a href="cn/XUL_Tutorial/More_Menu_Features#Adding_Checkmarks_to_Menus">XUL tutorial</a></p>

<p></p>
</div> <div id="a-validate">

<dl>
 <dt>
  <code id="a-validate"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/validate">validate</a></code></dt>
 <dd>
  Type:
  <i>
   one of the values below</i>
 </dd>
 <dd>
  This attribute indicates whether to load the image from the cache or not. This would be useful if the images are stored remotely or you plan on swapping the image frequently. The following values are accepted, or leave out the attribute entirely for default handling:</dd>
</dl>
<ul>
 <li><code>always</code>: The image is always checked to see whether it should be reloaded.</li>
 <li><code>never</code>: The image will be loaded from the cache if possible.</li>
</ul>

<p></p>
</div> <div id="a-value">

<dl>
 <dt>
  <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code></dt>
 <dd>
  Type:
  <i>
   string</i>
 </dd>
 <dd>
  The string attribute allows you to associate a data value with an element. It is not used for any specific purpose, but you can access it with a script for your own use.</dd>
</dl>

<p></p>
</div><p></p>
<h3 id="Properties" name="Properties">Properties</h3>
<p></p><div id="p-accessibleType">
<dl>
 <dt>
  <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessibleType">accessibleType</a></span></code></dt>
 <dd>
  Type:
  <i>
   integer</i>
 </dd>
 <dd>
  A value indicating the type of accessibility object for the element.</dd>
</dl>

<p></p></div> <div id="p-accessKey">
<dl>
 <dt>
  <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/accessKey">accessKey</a></span></code></dt>
 <dd>
  Type:
  <i>
   character</i>
 </dd>
 <dd>
  Gets and sets the value of the <code id="a-accesskey"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/accesskey">accesskey</a></code> attribute.</dd>
</dl>

<p></p></div> <div id="p-command">
<dl>
 <dt>
  <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/command">command</a></span></code></dt>
 <dd>
  Type:
  <i>
   element id</i>
 </dd>
 <dd>
  Gets and sets the value of the <code id="a-command"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/command">command</a></code> attribute.</dd>
</dl>

<p></p></div> <div id="p-menuitem.control">
<dl>
 <dt>
  <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menuitem.control">control</a></span></code></dt>
 <dd>
  Type:
  <i>
   <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> element</i>
 </dd>
 <dd>
  Returns the enclosing <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> that the item is inside, if any, or <code>null</code> if there is no enclosing menu.</dd>
</dl>

<p></p></div> <div id="p-crop">
<dl>
 <dt>
  <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/crop">crop</a></span></code></dt>
 <dd>
  Type:
  <i>
   string</i>
 </dd>
 <dd>
  Gets and sets the value of the <code id="a-crop"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/crop">crop</a></code> attribute.</dd>
</dl>

<p></p></div> <div id="p-disabled">
<dl>
 <dt>
  <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/disabled">disabled</a></span></code></dt>
 <dd>
  Type:
  <i>
   boolean</i>
 </dd>
 <dd>
  Gets and sets the value of the <code id="a-disabled"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/disabled">disabled</a></code> attribute.</dd>
</dl>

<p></p></div> <div id="p-image">
<dl>
 <dt>
  <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/image">image</a></span></code></dt>
 <dd>
  Type:
  <i>
   image URL</i>
 </dd>
 <dd>
  Gets and sets the value of the <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code> attribute.</dd>
</dl>

<p></p></div> <div id="p-label">
<dl>
 <dt>
  <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/label">label</a></span></code></dt>
 <dd>
  Type:
  <i>
   string</i>
 </dd>
 <dd>
  Gets and sets the value of the <code id="a-label"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/label">label</a></code> attribute.</dd>
</dl>

<p></p></div> <div id="p-labelElement">
<dl>
 <dt>
  <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/labelElement">labelElement</a></span></code></dt>
 <dd>
  Type:
  <i>
   <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/label" title="label">label</a></code> element</i>
 </dd>
 <dd>
  The <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/label" title="label">label</a></code> element associated with the control. This is set when a label has a <code id="a-control"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/control">control</a></code> attribute pointing to this element. This property will be <code>null</code> when no label is associated with the control.</dd>
</dl>

<p></p></div> <div id="p-parentContainer">
<dl>
 <dt>
  <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/parentContainer">parentContainer</a></span></code> </dt>
 <dd>
  Type:
  <i>
   <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> element</i>
 </dd>
 <dd>
  Read only property that returns the containing <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code> element, or <code>null</code> if there isn't a containing menu.</dd>
</dl>

<p></p></div> <div id="p-selected">
<dl>
 <dt>
  <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/selected">selected</a></span></code>&lt;magic name="\"PAGENAME\"/"&gt;&lt;/magic&gt;</dt>
 <dd>
  Type:
  <i>
   boolean</i>
 </dd>
 <dd>
  This property's value is <code>true</code> if this element is selected, or <code>false</code> if it is not. This property is read only.</dd>
</dl></div> <div id="p-tabIndex">
<dl>
 <dt>
  <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tabIndex">tabIndex</a></span></code></dt>
 <dd>
  Type:
  <i>
   integer</i>
 </dd>
 <dd>
  Gets and sets the value of the <code id="a-tabindex"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/tabindex">tabindex</a></code> attribute.</dd>
</dl>

<p></p></div> <div id="p-value">
<dl>
 <dt>
  <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/value">value</a></span></code></dt>
 <dd>
  Type:
  <i>
   string</i>
 </dd>
 <dd>
  Gets and sets the value of the <code id="a-value"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/value">value</a></code> attribute.</dd>
</dl>

<p></p></div> <table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited Properties</strong><br> <small> <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/align">align</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/allowEvents">allowEvents</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/boxObject">boxObject</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/builder">builder</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/className">className</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/collapsed">collapsed</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/contextMenu">contextMenu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/controllers">controllers</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/database">database</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/datasources">datasources</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/dir">dir</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/flex">flex</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/height">height</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/hidden">hidden</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/id">id</a></span></code>, , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/left">left</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxHeight">maxHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/maxWidth">maxWidth</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/menu">menu</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minHeight">minHeight</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/minWidth">minWidth</a></span></code>, , , , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/observes">observes</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ordinal">ordinal</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/orient">orient</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/pack">pack</a></span></code>, , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/persist">persist</a></span></code>, , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/ref">ref</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/resource">resource</a></span></code>, , , , , <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/statusText">statusText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/style">style</a></span></code>, ,, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltip">tooltip</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/tooltipText">tooltipText</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/top">top</a></span></code>, <code><span><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Property/width">width</a></span></code></small></p> </td> </tr> </tbody>
</table><p></p>
<h3 id="Methods" name="Methods">Methods</h3>
<p></p><table style="border: 1px solid rgb(204, 204, 204); margin: 0px 0px 10px 10px; padding: 0px 10px; background: rgb(238, 238, 238) none repeat scroll 0% 50%;"> <tbody> <tr> <td> <p><strong>Inherited from XUL element</strong><br> <small> <span id="m-blur"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/blur">blur</a></code></span>, <span id="m-click"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/click">click</a></code></span>, <span id="m-doCommand"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/doCommand">doCommand</a></code></span>, <span id="m-focus"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/focus">focus</a></code></span>, <span id="m-getElementsByAttribute"><code><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Method/getElementsByAttribute">getElementsByAttribute</a></code></span></small></p> <p><strong>Inherited from DOM element</strong><br> <small> <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.addEventListener">addEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.appendChild">appendChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.dispatchEvent">dispatchEvent()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttribute">getAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNode">getAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNodeNS">getAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getAttributeNS">getAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagName">getElementsByTagName()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttribute">hasAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributeNS">hasAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasAttributes">hasAttributes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.hasChildNodes">hasChildNodes()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.insertBefore">insertBefore()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.isSupported">isSupported()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.normalize">normalize()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttribute">removeAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNode">removeAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeAttributeNS">removeAttributeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeChild">removeChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.removeEventListener">removeEventListener()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.replaceChild">replaceChild()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttribute">setAttribute()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNode">setAttributeNode()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNodeNS">setAttributeNodeNS()</a></code>, <code><a href="https://developer.mozilla.org/zh-CN/docs/DOM/element.setAttributeNS">setAttributeNS()</a></code></small></p> </td> </tr> </tbody>
</table><p></p>
<h3 id="Style_classes" name="Style_classes">Style classes</h3>
<p></p><dl>
 <dt>
  <code><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Style/menuitem-iconic">menuitem-iconic</a></code></dt>
 <dd>
  Use this class to have an image appear on the <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>. Specify the image using the <code id="a-image"><a href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XUL/Attribute/image">image</a></code> attribute.</dd>
</dl>

<p></p> <dl>
 <dt>
  <code><a href="https://developer.mozilla.org/zh-CN/docs/XUL/Style/menuitem-non-iconic">menuitem-non-iconic</a></code></dt>
 <dd>
  Normally, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuitem" title="menuitem">menuitem</a></code>s have a margin to the left for an image or checkmark. This class may be used to remove this margin so that the menuitem appears on the left edge of the menupopup.</dd>
</dl>

<p></p><p></p>
<h3 id="Related" name="Related">Related</h3>
<dl>
 <dt>
  Elements</dt>
 <dd>
  <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menu" title="menu">menu</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menubar" title="menubar">menubar</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menulist" title="menulist">menulist</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menupopup" title="menupopup">menupopup</a></code>, <code><a href="/zh-CN/docs/Mozilla/Tech/XUL/menuseparator" title="menuseparator">menuseparator</a></code></dd>
</dl>
<dl>
 <dt>
  Interfaces</dt>
 <dd>
  <a href="cn/NsIAccessibleProvider">nsIAccessibleProvider</a>, <a href="cn/NsIDOMXULContainerItemElement">nsIDOMXULContainerItemElement</a>, <a href="cn/NsIDOMXULSelectControlItemElement">nsIDOMXULSelectControlItemElement</a></dd>
</dl>
<p> </p>
<div class="noinclude">
  </div>
<p></p>