我有如下的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>₹ 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 -->: <!-- /react-text --><span>₹ 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');在总票价之后插入一个div,但它没有产生预期的结果。
发布于 2018-04-03 19:10:12
您的appendTo不工作,因为没有名为col 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');发布于 2018-04-03 18:00:38
为此,请使用prependTo
$('<div id="calendar" class="col-lg-2 col-md-2 col-xs-2 no-padding-returnFlight"><b>+ Add Return Flight</b></div>').prependTo('.examplefooter-totalFare_wrap');发布于 2018-04-03 19:09:38
请从脚本中删除.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');https://stackoverflow.com/questions/49626870
复制相似问题