单击里面的按钮时添加bootstrap Alert消息

时间:2017-03-11 22:49:50

标签: html5 bootstrap-modal

我是bootstrap的新手。当我点击表格列中的按钮(添加项目到购物车)时,如何添加引导警报成功消息" self.device" ?

<td>

是。我已经阅读了很多教程,但无法弄明白。它变得一团糟。

更新 我认为我想到的解决方案可以解决。

HTML:       `

  <td align="center">
  <input type="number" min="1" max="20" step="1" value="1" style="width:90px;margin-bottom:10px;margin-top:20px;">
  <button type="button" class="btn btn-default btn-sm">
  <span id="cart" class="glyphicon glyphicon-shopping-cart"></span> Cart </button>
  </td>

JQuery的:

data-dismiss = "alert" ng-click="addProductToCart(product)">

 <span id="cart" class="glyphicon glyphicon-shopping-  cart">   

</span>Kundvagn</button>
 <div id="myAlert" class="alert alert-success hide">
 Varan har lagts till ordern.
                </div>`

1 个答案:

答案 0 :(得分:1)

试试这个:

    <!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>Modal Example</h2>
  <!-- Trigger the modal with a button -->
  <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal"><span id="cart" class="glyphicon glyphicon-shopping-cart"></span> Cart </button>

  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">

      <!-- Modal content-->
      <div class="modal-content">

     <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">
            <span class="glyphicon glyphicon-name"></span> &times;</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
          <p>Successfully added to cart</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
       </div>

    </div>
  </div>

</div>

</body>
</html>