追加()不起作用

时间:2018-04-03 09:40:48

标签: jquery html

我的html为:

<div class="oneWay examplefooter" style="display: block;">
   <div class="container mobile-row">
      <div class="examplefooter-sum col-lg-1 col-md-1 nopadding ">
         <b>
            <!-- react-text: 6 -->Price<!-- /react-text --><!-- react-text: 7 --> <!-- /react-text --><br><!-- react-text: 9 --> <!-- /react-text --><!-- react-text: 10 -->Summary<!-- /react-text -->
         </b>
      </div>
      <div class="col-lg-7 col-md-7 col-xs-9 col-lg-offset-2 col-md-offset-2 no-padding-mobile arrow-wrapper">
         <div>
            <div class="examplefooter-totalWrap" id="trip0">
               <!-- react-text: 41 --> <!-- /react-text -->
               <div class="examplefooter-totalWrap_place">
                  <!-- react-text: 43 -->DEL<!-- /react-text --><!-- react-text: 44 --> - <!-- /react-text --><!-- react-text: 45 -->BLR<!-- /react-text -->
               </div>
               <div class="examplefooter-totalWrap_time">
                  <!-- react-text: 47 -->6E<!-- /react-text --><!-- react-text: 48 --> <!-- /react-text --><!-- react-text: 49 --> 133<!-- /react-text -->
                  <span class="time">
                     <!-- react-text: 51 -->05:05<!-- /react-text --><!-- react-text: 52 --> - <!-- /react-text --><!-- react-text: 53 -->07:50<!-- /react-text -->
                  </span>
               </div>
               <div class="examplefooter-totalWrap_price">
                  <div class="triangle-up small"></div>
                  <span>₹&nbsp;2,473</span>
                  <div class="cfd">(Click for details)</div>
               </div>
               <!-- react-empty: 58 -->
            </div>
         </div>
         <div class="examplefooter-totalFare_wrap">
            <div class="examplefooter-totalFare">
               <div class="triangle-up"></div>
               <span id="totalSummary">
                  <!-- react-text: 63 --> <!-- /react-text --><!-- react-text: 64 -->Total<!-- /react-text --><!-- react-text: 65 -->:  &nbsp;<!-- /react-text --><span>₹&nbsp;2,473</span>
               </span>
               <div class="cfd small">(Click for details)</div>
               <!-- react-empty: 68 -->
            </div>
         </div>
      </div>
      <div class="col-lg-2 col-md-2 col-xs-3 nopadding">
         <button class="yelbtn">
            <span>
               <!-- react-text: 35 -->Continue<!-- /react-text --><!-- react-text: 36 --> <!-- /react-text --><i class="fa icon-chevron-right" aria-hidden="true"></i>
            </span>
         </button>
      </div>
   </div>
</div>

我正在使用此命令:

$('<div id="calendar" class="col-lg-2 col-md-2 col-xs-2 no-padding-returnFlight"><b>+ Add Return Flight</b></div>').appendTo('.col-sm-3.examplefooter-totalFare_wrap');

在Total Fare之后插入一个div,但它没有产生我想要的结果。

3 个答案:

答案 0 :(得分:1)

你的appendTo无法正常工作,因为没有名为col-sm-3的类。仅使用examplefooter-totalFare_wrap进行追加。

试试这个,

$('<div id="calendar" class="col-lg-2 col-md-2 col-xs-2 no-padding-returnFlight"><b>+ Add Return Flight</b></div>').appendTo('.examplefooter-totalFare_wrap');

答案 1 :(得分:0)

将<{1}}用于此

prependTo

答案 2 :(得分:-1)

请从脚本中删除.col-sm-3类

  $('<div id="calendar" class="col-lg-2 col-md-2 col-xs-2 no-padding-returnFlight"><b>+ Add Return Flight</b></div>').appendTo('.examplefooter-totalFare_wrap');