最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

bootstrap彈出層的多種觸發(fā)方式

 更新時(shí)間:2017年05月10日 08:45:38   作者:米米余  
這篇文章主要為大家詳細(xì)介紹了bootstrap彈出層的多種觸發(fā)方式,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

bootstrap彈出層有多種觸發(fā)方式,以下是我用到的幾種方式:

1.方法一:button中屬性觸發(fā)

注意:button中的data-target內(nèi)容應(yīng)該和要和彈出層中的id保持一致
data-target=”#mymodal-data”——– id=”mymodal-data”

<!--在button上綁定觸發(fā)彈出層的屬性-->
 <button class="btn btn-primary delete" data-toggle="modal"
  data-target="#mymodal-data" data-whatever="@mdo">
  修改
</button>

<!-- 模態(tài)彈出窗內(nèi)容 -->
<div class="modal" id="mymodal-data" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
 <div class="modal-dialog">
 <div class="modal-content">
  <div class="modal-header">
  <button type="button" class="close" data-dismiss="modal">
   <span aria-hidden="true">&times;</span>
   <span class="sr-only">Close</span>
  </button>
  <h4 class="modal-title">彈出層標(biāo)題</h4>
  </div>
  <div class="modal-body">
  <p>彈出層主體內(nèi)容</p>
  </div>
  <div class="modal-footer">
  <button type="button" class="btn btn-default" data-dismiss="modal">關(guān)閉</button>
  <button type="button" class="btn btn-primary">保存</button>
  </div>
 </div>
 </div>
</div>

結(jié)果:

這里寫圖片描述

2.方法二:通過js綁定

注意:將button的id和彈出層的id分別賦給 $m_btn和$modal,當(dāng)$m_btn被點(diǎn)擊后$modal彈出。

<button class="btn btn-info" type="button" id="y-modalBtnAdd" > <label >添加</label></button>


<!-- 模態(tài)彈出窗內(nèi)容 -->
<div class="modal" id="y-myModalAdd" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
 <div class="modal-dialog">
 <div class="modal-content">
  <div class="modal-header">
  <button type="button" class="close" data-dismiss="modal">
   <span aria-hidden="true">&times;</span>
   <span class="sr-only">Close</span>
  </button>
  <h4 class="modal-title">彈出層標(biāo)題</h4>
  </div>
  <div class="modal-body">
  <p>通過js綁定button和彈出層觸發(fā)</p>
  </div>
  <div class="modal-footer">
  <button type="button" class="btn btn-default" data-dismiss="modal">關(guān)閉</button>
  <button type="button" class="btn btn-primary">保存</button>
  </div>
 </div>
 </div>
</div>
<!--js代碼-->
<script type="text/javascript">
 $(function(){
 // dom加載完畢
 var $m_btn = $('#y-modalBtnAdd'); //y-modalBtnAdd是button的id
 var $modal = $('#y-myModalAdd'); //y-myModalAdd是彈出的遮罩層的id,通過這兩個(gè)id進(jìn)行綁定
 $m_btn.on('click', function(){
  $modal.modal({backdrop: 'static'});
 });
 });
 </script>

結(jié)果:

這里寫圖片描述

3.方法三:點(diǎn)擊表格一行,彈出彈出層

動(dòng)態(tài)給tr標(biāo)簽加彈出的觸發(fā)屬性

<!--表格-->
<table class="table table-bordered " style="width: 400px">
 <thead>
 <tr>
  <th>一</th>
  <th>二</th>
  <th>三</th>
 </tr>
 </thead>
 <tbody class="tableBody">
 <tr>
  <td>one</td>
  <td>two</td>
  <td>three</td>
 </tr>
 <tr>
  <td>four</td>
  <td>five</td>
  <td>six</td>
 </tr>
 </tbody>
</table>

<!-- 模態(tài)彈出窗內(nèi)容 -->
<div class="modal" id="mymodal-data" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
 <div class="modal-dialog">
 <div class="modal-content">
  <div class="modal-header">
  <button type="button" class="close" data-dismiss="modal">
   <span aria-hidden="true">&times;</span>
   <span class="sr-only">Close</span>
  </button>
  <h4 class="modal-title">彈出層標(biāo)題</h4>
  </div>
  <div class="modal-body">
  <p>點(diǎn)擊表格一行內(nèi)容,彈出彈出層</p>
  </div>
  <div class="modal-footer">
  <button type="button" class="btn btn-default" data-dismiss="modal">關(guān)閉</button>
  <button type="button" class="btn btn-primary">保存</button>
  </div>
 </div>
 </div>
</div>


<!--js代碼-->
<script type="text/javascript">
 $(function () {
 $(".tableBody>tr").each(function () {
  $(this).on("click",function () {
  $(this).attr({"data-toggle":"modal","data-target":"#mymodal-data","data-whatever":"@mdo"});

  })
 });
 });
</script>

結(jié)果:

這里寫圖片描述

這里寫圖片描述

bootstrap的彈出層在整個(gè)屏幕的上半部分,可以將它居中顯示。(方法二可以讓彈出層居中顯示)

$(function(){
 // dom加載完畢
 var $m_btn = $('#y-modalBtnAdd'); y-modalBtnAdd是button的id
 var $modal = $('#y-myModalAdd'); y-myModalAdd是彈出的遮罩層的id,通過這兩個(gè)id進(jìn)行綁定 
 // 測(cè)試 bootstrap 居中 ,bootstrap的彈出層默認(rèn)是左右居中,上下則是偏上,此代碼將彈出層上下也居中了,但是會(huì)抖
   動(dòng)一下
 $modal.on('shown.bs.modal', function(){
  var $this = $(this);
  var $modal_dialog = $this.find('.modal-dialog');
  var m_top = ( $(document).height() - $modal_dialog.height() )/2;
  $modal_dialog.css({'margin': m_top + 'px auto'});
 });
 });
</script>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 微信小程序使用template標(biāo)簽實(shí)現(xiàn)五星評(píng)分功能

    微信小程序使用template標(biāo)簽實(shí)現(xiàn)五星評(píng)分功能

    這篇文章主要為大家詳細(xì)介紹了微信小程序使用template標(biāo)簽實(shí)現(xiàn)五星評(píng)分功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-11-11
  • js或css文件后面跟參數(shù)的原因說明

    js或css文件后面跟參數(shù)的原因說明

    經(jīng)常看到不少導(dǎo)航網(wǎng)站測(cè)樣式或js文件后面加了一些參數(shù),主要是一你為一些并不經(jīng)常更新的頁(yè)面重新加載新修改的文件。
    2010-01-01
  • 前端滾動(dòng)錨點(diǎn)三個(gè)常用方案(點(diǎn)擊后頁(yè)面滾動(dòng)到指定位置)

    前端滾動(dòng)錨點(diǎn)三個(gè)常用方案(點(diǎn)擊后頁(yè)面滾動(dòng)到指定位置)

    這篇文章主要給大家介紹了關(guān)于前端滾動(dòng)錨點(diǎn)的三個(gè)常用方案,實(shí)現(xiàn)的效果就是點(diǎn)擊后頁(yè)面滾動(dòng)到指定位置,三種方法分別是scrollIntoView、scrollTo和scrollBy,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2025-01-01
  • js實(shí)現(xiàn)簡(jiǎn)易ATM功能

    js實(shí)現(xiàn)簡(jiǎn)易ATM功能

    這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)簡(jiǎn)易ATM功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-10-10
  • JavaScript單元測(cè)試ABC

    JavaScript單元測(cè)試ABC

    在服務(wù)器端的單元測(cè)試中,都有各種各樣的測(cè)試框架,在JavaScript中現(xiàn)在也有一些很優(yōu)秀的框架,但在本文中,我們將自己動(dòng)手一步步來(lái)實(shí)現(xiàn)一個(gè)簡(jiǎn)單的單元測(cè)試框架
    2012-04-04
  • 深入淺析JavaScript中with語(yǔ)句的理解

    深入淺析JavaScript中with語(yǔ)句的理解

    JavaScript 有個(gè) with 關(guān)鍵字, with 語(yǔ)句的原本用意是為逐級(jí)的對(duì)象訪問提供命名空間式的速寫方式。這篇文章主要介紹了JavaScript中with語(yǔ)句的相關(guān)知識(shí),感興趣的朋友一起學(xué)習(xí)吧
    2016-05-05
  • 微信小程序JSON配置文件詳細(xì)講解作用

    微信小程序JSON配置文件詳細(xì)講解作用

    JSON是一種數(shù)據(jù)格式,在實(shí)際開發(fā)中,JSON總是以配置文件的形式出現(xiàn)。小程序項(xiàng)目中也不例外:通過不同的Json配置文件,可以對(duì)小程序項(xiàng)目進(jìn)行不同級(jí)別的配置
    2022-10-10
  • JavaScript數(shù)據(jù)類型檢測(cè)實(shí)現(xiàn)方法詳解

    JavaScript數(shù)據(jù)類型檢測(cè)實(shí)現(xiàn)方法詳解

    Javascript中檢查數(shù)據(jù)類型一直是老生常談的問題,類型判斷在web開發(fā)中也有著非常廣泛的應(yīng)用,所以下面這篇文章主要給大家介紹了關(guān)于JS數(shù)據(jù)類型檢測(cè)的那些事,需要的朋友可以參考下
    2022-11-11
  • 用Javascript 編寫可以緩慢彈出收縮的層

    用Javascript 編寫可以緩慢彈出收縮的層

    前天老師布置了一道思考題,用Javascript編寫可以緩慢彈出收縮的層,折騰了好幾個(gè)小時(shí),總算寫出效果.
    2009-10-10
  • JavaScript和TypeScript中的void的具體使用

    JavaScript和TypeScript中的void的具體使用

    這篇文章主要介紹了JavaScript和TypeScript中的void的具體使用,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09

最新評(píng)論

清流县| 惠安县| 雅安市| 濮阳县| 凉山| 湖州市| 泸西县| 天台县| 长子县| 长葛市| 织金县| 怀宁县| 若尔盖县| 萨迦县| 卢龙县| 淄博市| 平武县| 湘西| 新源县| 大石桥市| 会昌县| 临高县| 巴东县| 嘉禾县| 伊春市| 曲水县| 盈江县| 建始县| 专栏| 兴安县| 沙坪坝区| 澄迈县| 分宜县| 洛浦县| 延寿县| 从江县| 阿鲁科尔沁旗| 年辖:市辖区| 普宁市| 哈密市| 额尔古纳市|