可以在div上使用optgroup选项吗?

时间:2014-03-22 15:54:40

标签: optgroup

有这个optgroup选择它可以使用javascript为此,如果是的话可以告诉我一个例子我怎么做我环顾四周但我找不到什么?

Choose a city:
<select name="city">
  <optgroup label="color_1">
    <option value="Blue">Blue</option>
    <option value="Red">Red</option>
    <option value="Green">Green</option>
  </optgroup>
  <optgroup label="Colors 2"> 
    <option value="Yellow">Yellow</option> 
    <option value="Grey">Grey</option> 
    <option value="White">White</option> 
  </optgroup> 
</select>

But i want use group for div class for example

<div class="categories">


<span class="optgroup" id="color_1">
   <div class="category">Colors 1</div>
  <label class="color_1">Blue</label>
  <label class="color_1">Red</label>
  <label class="color_1">Green</label>
</span>

<span class="optgroup" id="color_2">
   <div class="category">Colors 2</label >
      <label class="color_2">Yellow</label>
  <label class="color_2">Grey</label>
  <label class="color_2">White</label>
</span>

</div>

0 个答案:

没有答案