开发者

How to wrap a div in jQuery?

I have a selectbox:

<select>
  <option value="opt1">Optie nummer 1</option>
  <option value="opt2">Optie nummer 2</option>
  <option value="opt3">Optie nummer 3</option>
</select>

With a plugin I style the select boxes and then the HTML become:

<div class="sb-cust开发者_运维问答om">
  <select tabindex="-1">
    <option value="opt1">Optie nummer 1</option>
    <option value="opt2">Optie nummer 2</option>
    <option value="opt3">Optie nummer 3</option>
  </select>

  <input type="text" class="sb-select" readonly="readonly">

  <ul class="sb-dropdown">
    <li class="selected"><a href=".">Optie nummer 1</a></li>
    <li><a href=".">Optie nummer 2</a></li>
    <li><a href=".">Optie nummer 3</a></li>
  </ul>
</div>

Now I want when I add the class small add the selectbox that the div "sb-costum" get a the class small extra. So you get <div class="sb-custom small">


$(".sb-custom").addClass("small")

That should do it. See here for more details http://docs.jquery.com/Addclass


I have found my answer:

$('.bottom table.form tr td select.small').parent(".sb-custom").addClass("small");


hi here is one of the solutions to wrap and entire element into a div.

   $(document).ready(function(){
         $('h3').each(function(){
          $(this).add( $(this).next() ).wrapAll('<div class="box"></div>');
         })
        })
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜