使用Jquery删除Jquery Chosen的默认样式

时间:2014-11-29 07:22:56

标签: javascript jquery

我们如何使用Jquery或javascript删除一些Jquery Chosen样式。我想从'selected-drop'类中删除'top:100%'属性。我试过了$('.ddlDpndtRsrc').find('.chosen-container .chosen-drop').css('top','');,但它没有用。

<div class="controlsDiv ddlDpndtRsrc">
    <select data-placeholder="Select" id="ddlDependentResource" name="dependent_resource" data-col="DependentResource" class="infoInput chsnddl" style="display: none;">
        <option value="-1"></option>
        <option value="3">Business visa</option>

    </select>
    <div class="chosen-container chosen-container-single" style="width: 90%;" title="" id="ddlDependentResource_chosen"><a class="chosen-single chosen-default" tabindex="-1"><span>Select</span><div><b></b></div></a>
        <div class="chosen-drop" style="top: 0px;">
            <div class="chosen-search">
                <input type="text" autocomplete="off">
            </div>
            <ul class="chosen-results">
                <li class="active-result" style="" data-option-array-index="1">Business visa</li>


            </ul>
        </div>
    </div>
</div>

2 个答案:

答案 0 :(得分:0)

将您的HTML帖子设置为可读之后,您提供的内容应该有效,请确保.chosen-container .chosen-drop尚未!important覆盖top值。

习惯用[{1}}取代<b>也可能是个好主意:)

答案 1 :(得分:0)

HTML

<!DOCTYPE html>
    <html>
    <head>
    <script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
      <meta charset="utf-8">
      <title>JS Bin</title>
    </head>
    <body>
      <div class="ddlDpndtRsrc">
        <div class="chosen-container chosen-drop">
          Dummy text
        </div>
      </div>
    </body>
    </html>

JAVASCRIPT

 var element = $('.ddlDpndtRsrc').find('.chosen-container.chosen-drop');
    element.css({
      'top' : '0%'
    });

http://jsbin.com/niyadi/3/watch