【发布时间】:2015-07-16 03:32:07
【问题描述】:
我正在使用使用 SmartAdmin 主题的引导程序。
它将所有 html 结构转换为 <section><div> struct include <select><option>。
所以我的输出如下所示。
<section id="00000001" class="col col-md-6">
<label class="label">SomeLabel
<sapn class="cp_id_text"></sapn>
</label>
<label class="select">
<div class="select2-container form-hidden-control" id="s2id_00000001" title="" style="width: 100%;"><a href="javascript:void(0)" class="select2-choice" tabindex="-1"> <span class="select2-chosen" id="select2-chosen-9">20th Century Fox Film Corporation(00000001)</span><abbr class="select2-search-choice-close"></abbr> <span class="select2-arrow" role="presentation"><b role="presentation"></b></span></a><label for="s2id_autogen9" class="select2-offscreen"></label><input class="select2-focusser select2-offscreen" type="text" aria-haspopup="true" role="button" aria-labelledby="select2-chosen-9" id="s2id_autogen9"></div><input type="text" class="form-hidden-control select2-offscreen" id="00000001" name="cp_id" value="" data-init-text="" inputtype="select" title="" maxlength="50" tabindex="-1">
<script>$("#00000001").select2(selects2Option('00000002','cp_id'));</script>
</label>
<script>
$("#00000001").attr("maxlength", "50");
</script>
</section>
由于我找不到任何<select> 标签,我不能使用 selected 属性来设置默认值。
我可以通过 jquery parent(), find() 等找到它,但这看起来效率不高。有什么方法可以像 selected 这样简单地处理吗?
SmartAdmin 网站说他们使用 select2 api,但他们没有提到如何将值设置为默认值。
网站:http://192.241.236.31/smartadmin/BUGTRACK/track_/documentation/index.html#!/introduction
谢谢。
【问题讨论】:
标签: jquery twitter-bootstrap select smartadmin