当我用<div>

时间:2015-11-04 09:51:41

标签: javascript jquery html css twitter-bootstrap

我的引导程序下拉有问题。当我用div附加它时它不起作用。并克隆了第一个..我想再次展示引导风格,但引导风格不起作用

JS

$(document).ready(function() {


      var max_fields = 8; //maximum input boxes allowed
      var wrapper = $(".input_fields_wrap1"); //Fields wrapper
      var add_button = $("#add_field_button1"); //Add button ID
      var x = 1



      //initlal text box count
      $(add_button).click(function(e) { //on add input button click

            e.preventDefault();
            if (x < max_fields) { //max input box allowed
              x++; //text box increment


              <? php $wqeqw = 1;
              while ($wqeqw <= 8) {

                $wqeqw++;
              } ?>


              $(wrapper).append("<div>" +
                  "<select  name='item_packing[]'  data-placeholder='Click here to select' multiple class='form-control chzn-select  chzn-rtl' tabindex='10'>" +
                  "<option value='AAA'>AAA</option>" +
                  "<option value='BBB'>BBB</option>" +
                  "<option value='CCC'>CCC</option>" +
                  "<option value='DDD'>DDD</option>" +

                  "</select>" +  // Incomplete Code . OP has to update this part

HTML

<div class="input_fields_wrap1">

  <select style="height:12350x;" name="item[]" data-placeholder="Click here to select" multiple class="form-control chzn-select  chzn-rtl" tabindex="10">
    <option value="AAA">AAA</option>
    <option value="BBB">BBB</option>
    <option value="CCC">CCC</option>
    <option value="DDD">DDD</option>
  </select>
</div>
<button id="add_field_button1" class="btn btn-success" onclick="fetch_select1();"><i class="glyphicon glyphicon-plus"></i> Add Another Item</button>

2 个答案:

答案 0 :(得分:0)

您已初始化

var add_button = $(“#add_field_button1”);

添加不带$

的点击事件
add_button.click(function(){
});

相同

将$(wrapper).append()更改为wrapper.append();

答案 1 :(得分:-1)

我认为你应该首先尝试找出问题是什么,删除所有可能在你的document.ready函数中并且只将你的附加代码...如果它不起作用那么你就会知道问题出在附加行中,将问题的范围缩小到第一级