如何在我的html文件中使用选定的jQuery? [英] How do I use Chosen jQuery in my html file?

查看:108
本文介绍了如何在我的html文件中使用选定的jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个选择表单,所以我需要通过Chosen使用多个选择使它看起来更加用户友好。

 < select class =selectedmultiple =truename =faculty> 
< option value =AC> A< / option>
< option value =AD> B< / option>
< option value =AM> C< / option>
< option value =AP> D< / option>
< / select>

我已经下载了这些文件并将其复制到了我的网页文件夹中。



因此,我所做的是在< head> chosen.jquery.min.js c $ c>:

 < script type =text / javascriptsrc =selected / chosen.jquery.min。 JS>< /脚本> 

并且该指令表示调用所选插件: $(。chzn -select)。chosen();



我不知道该放哪个JavaScript语句以便调用选择多个select。我认为这和使用Bootstrap一样简单,哈哈。任何帮助?

.html#examplesrel =noreferrer> Bootstrap的示例标记结构,您会注意到它们将其底部的所有JavaScript文件(位于< / body> 标签)。



你会想要做同样的事情;例如:

 < / div> <! -  / container  - > 

<! - Le javascript
=============================== =================== - >
<! - 放置在文档的末尾,以便页面加载更快 - >
< script src =../ assets / js / jquery.js>< / script>
< script src =../ assets / js / bootstrap-transition.js>< / script>
< script src =../ assets / js / bootstrap-alert.js>< / script>
< script src =../ assets / js / script.js>< / script> <! - 您的自定义JS - >

< / body>
< / html>

在这个 script.js 文件中,您'

  $(function(){
$(。chzn-select ).chosen();
});


How do I apply Chosen jQuery in my html page?

I have a select form so I need to use the multiple select by Chosen to make it look more user friendly.

<select class="chosen" multiple="true" name="faculty">
        <option value="AC">A</option>
        <option value="AD">B</option>
        <option value="AM">C</option>
        <option value="AP">D</option>
</select>

I've downloaded the files and copied it into my webpage folder.

So, what I did was include the chosen.jquery.min.js in <head>:

<script type="text/javascript" src="chosen/chosen.jquery.min.js"></script>

And the instruction says to Call the chosen plugin: $(".chzn-select").chosen();

I don't know where to put that JavaScript statement in order to invoke Chosen multiple select. I thought it was as easy as using Bootstrap, hah. Any help?

解决方案

If you follow one of Bootstrap's example markup structures, you'll notice that they call all their JavaScript files at the bottom (right above the </body> tag).

You'll want to do the same; something like:

    </div> <!-- /container -->

    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="../assets/js/jquery.js"></script>
    <script src="../assets/js/bootstrap-transition.js"></script>
    <script src="../assets/js/bootstrap-alert.js"></script>
    <script src="../assets/js/script.js"></script>     <!-- Your custom JS -->

  </body>
</html>

Inside this script.js file, you'll want to add something like:

$(function(){
    $(".chzn-select").chosen();
});

这篇关于如何在我的html文件中使用选定的jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆