Nqa Bootstrap cov khoom rau lub neej-tam sim no nrog 13 kev cai jQuery plugins.
Plugins tuaj yeem suav nrog tus kheej (txawm tias qee qhov yuav tsum muaj kev vam khom), lossis tag nrho ib zaug. Ob leeg bootstrap.js thiab bootstrap.min.js muaj tag nrho cov plugins hauv ib cov ntaub ntawv.
Koj tuaj yeem siv tag nrho Bootstrap plugins nkaus xwb los ntawm markup API yam tsis tau sau ib kab ntawm JavaScript. Qhov no yog Bootstrap thawj chav kawm API thiab yuav tsum yog koj thawj qhov kev txiav txim siab thaum siv lub plugin.
Uas tau hais tias, hauv qee qhov xwm txheej nws yuav tsim nyog los tua qhov kev ua haujlwm no. Yog li ntawd, peb kuj muab lub peev xwm los lov tes taw cov ntaub ntawv attribute API los ntawm unbinding tag nrho cov xwm txheej ntawm lub cev namespaced nrog 'data-api''. Qhov no zoo li no:
- $ ( 'lub cev' ). tawm ( '.data-api' )
Xwb, txhawm rau tsom ib lub plugin tshwj xeeb, tsuas yog suav nrog lub plugin lub npe ua lub npe chaw nrog rau cov ntaub ntawv-api namespace zoo li no:
- $ ( 'lub cev' ). tawm ( '.alert.data-api' )
Peb kuj ntseeg tias koj yuav tsum tuaj yeem siv tag nrho Bootstrap plugins nkaus xwb los ntawm JavaScript API. Tag nrho cov pej xeem APIs yog ib leeg, chainable txoj kev, thiab xa rov qab cov sau ua raws li.
- $ ( ".btn.danger" ). khawm ( "toggle" ). addClass ( "fat" )
Txhua txoj hauv kev yuav tsum lees txais qhov kev xaiv xaiv khoom, ib txoj hlua uas tsom rau ib txoj hauv kev, lossis tsis muaj dab tsi (uas pib lub plugin nrog tus cwj pwm tsis zoo):
- $ ( "#myModal" ). modal () // pib nrog defaults
- $ ( "#myModal" ). modal ({ keyboard : cuav }) // pib nrog tsis muaj keyboard
- $ ( "#myModal" ). modal ( 'show' ) // pib thiab invokes qhia tam sim
Txhua lub plugin kuj nthuav tawm nws cov neeg tsim khoom nyoos ntawm 'Constructor' cov cuab yeej: $.fn.popover.Constructor
. Yog tias koj xav tau ib qho plugin tshwj xeeb, muab nws ncaj qha los ntawm lub caij: $('[rel=popover]').data('popover')
.
Qee zaum nws yog qhov tsim nyog los siv Bootstrap plugins nrog rau lwm qhov UI lub luag haujlwm. Hauv cov xwm txheej no, kev sib tsoo ntawm lub npe chaw tuaj yeem tshwm sim qee zaus. Yog tias qhov no tshwm sim, koj tuaj yeem hu .noConflict
rau lub plugin koj xav rov qab tus nqi ntawm.
- var bootstrapButton = $ . fn kev . khawm . noConflict () // xa $.fn.button rau yav tas los tus nqi
- $ . fn kev . bootstrapBtn = bootstrapButton // muab $().bootstrapBtn lub bootstrap functionality
Bootstrap muab cov xwm txheej kev cai rau feem ntau plugin qhov tshwj xeeb ua. Feem ntau, cov no tuaj nyob rau hauv daim ntawv infinitive thiab yav dhau los koom nrog - qhov twg qhov infinitive (ex. show
) tshwm sim thaum pib ntawm ib qho kev tshwm sim, thiab nws daim ntawv koom nrog yav dhau los (ex. shown
) yog tshwm sim ntawm qhov ua tiav ntawm qhov kev txiav txim.
Tag nrho cov xwm txheej infinitive muab kev tiv thaivDefault functionality. Qhov no muab lub peev xwm los nres qhov kev txiav txim ua ntej nws pib.
- $ ( '#myModal' ). ntawm ( 'show' , function ( e ) {
- yog tias (! data ) rov e . PreventDefault () // nres modal los ntawm kev qhia
- })
Rau kev hloov pauv yooj yim, suav nrog bootstrap-transition.js ib zaug nrog rau lwm cov ntaub ntawv JS. Yog tias koj siv cov compiled (los yog minified) bootstrap.js , tsis tas yuav suav nrog qhov no - nws twb muaj lawm.
Qee qhov piv txwv ntawm kev hloov pauv plugin:
Modals yog streamlined, tab sis saj zawg zog, dialog prompts nrog yam tsawg kawg nkaus yuav tsum tau functionality thiab ntse defaults.
Ib tug rendered modal nrog header, lub cev, thiab txheej ntawm kev ua nyob rau hauv lub footer.
Ib lub cev zoo…
- <div class = "modal hide fade" >
- <div class = "modal-header" >
- <button type = "button" class = "kaw" data-dismiss = "modal" aria-hidden = "true" > × </button>
- <h3> Modal header </h3>
- </div>
- <div class = "modal-body" >
- <p> Ib lub cev zoo… </p>
- </div>
- <div class = "modal-footer" >
- <a href="#" class="btn"> Kaw </a> _ _ _ _ _
- <a href="#" class="btn btn-primary"> Txuag hloov pauv </a> _ _
- </div>
- </div>
Toggle modal ntawm JavaScript los ntawm nias lub pob hauv qab no. Nws yuav swb thiab ploj mus los ntawm sab saum toj ntawm nplooj ntawv.
- <!-- Khawm los ua qauv qauv -->
- <a href="#myModal" role="button" class="btn" data-toggle = "modal"> Launch demo modal </a> _ _ _ _ _
- <!-- Modal -->
- <div id = "myModal" class = "modal hide fade" tabindex = "-1" role = "dialog" aria-labeledby = "myModalLabel" aria-hidden = "true" >
- <div class = "modal-header" >
- <button type = "button" class = "kaw" data-dismiss = "modal" aria-hidden = "true" > × </button>
- <h3 id = "myModalLabel" > Modal header </h3>
- </div>
- <div class = "modal-body" >
- <p> Ib lub cev zoo… </p>
- </div>
- <div class = "modal-footer" >
- <button class = "btn" data-dismiss = "modal" aria-hidden = "true" > Kaw </button>
- <button class = "btn btn-primary" > Txuag hloov pauv </button>
- </div>
- </div>
Qhib lub modal yam tsis tau sau JavaScript. Teem data-toggle="modal"
rau ntawm tus tswj lub caij, zoo li lub pob, nrog rau ib data-target="#foo"
lossis href="#foo"
rau lub hom phiaj ib qho kev hloov pauv.
- <khawm hom = "button" data-toggle = "modal" data-target = "#myModal" > Launch modal </button>
Hu rau modal nrog id myModal
nrog ib kab ntawm JavaScript:
- $ ( '#myModal' ). modal ( kev xaiv )
Cov kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript. Rau cov ntaub ntawv tus cwj pwm, ntxiv rau qhov kev xaiv npe rau data-
, xws li hauv data-backdrop=""
.
Lub npe | hom | ua ntej | piav qhia |
---|---|---|---|
keeb kwm yav dhau | boolean | muaj tseeb | Xws li ib qho modal-backdrop element. Xwb, qhia meej static rau ib qho backdrop uas tsis kaw lub modal ntawm nias. |
keyboard | boolean | muaj tseeb | Kaw lub modal thaum khiav qhov tseem ceeb yog nias |
ua yeeb yam | boolean | muaj tseeb | Qhia cov modal thaum pib. |
nyob deb | txoj kev | cuav | Yog hais tias ib tug tej thaj chaw deb url yog muab, cov ntsiab lus yuav loaded ntawm jQuery txoj
|
Activates koj cov ntsiab lus raws li ib tug modal. Txais ib qho kev xaiv xaiv object
.
- $ ( '#myModal' ). modal ({
- keyboard : cuav
- })
Manually toggles ib modal.
- $ ( '#myModal' ). modal ( 'toggle' )
Manually qhib lub modal.
- $ ( '#myModal' ). modal ( 'qhia' )
Manually hides ib modal.
- $ ( '#myModal' ). modal ( 'Hide' )
Bootstrap's modal class exposes ob peb txheej xwm rau hooking rau hauv modal functionality.
Kev tshwm sim | Kev piav qhia |
---|---|
ua yeeb yam | Qhov xwm txheej no tua hluav taws tam sim ntawd thaum show hu ua piv txwv. |
qhia | Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub modal tau ua kom pom rau tus neeg siv (yuav tos rau css kev hloov pauv kom tiav). |
zais | Qhov xwm txheej no raug rho tawm haujlwm tam sim ntawd thaum hide hu ua piv txwv txoj kev. |
zais cia | Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub modal tiav lawm muab zais los ntawm tus neeg siv (yuav tos rau css hloov mus ua kom tiav). |
- $ ( '#myModal' ). ntawm ( 'hidden' , function () {
- // ua ib yam dab tsi…
- })
Ntxiv dropdown menus rau yuav luag txhua yam nrog no yooj yim plugin, nrog rau cov navbar, tabs, thiab tshuaj.
Ntxiv data-toggle="dropdown"
rau qhov txuas lossis khawm kom toggle ib qho kev poob.
- <div class = "dropdown" >
- <a class = "dropdown-toggle" data-toggle = "dropdown" href = "#" > Dropdown trigger </a>
- <ul class = "dropdown-menu" role = "menu" aria-labeledby = "dLabel" >
- ...
- </ul>
- </div>
Txhawm rau khaws URLs kom zoo, siv tus data-target
cwj pwm tsis yog href="#"
.
- <div class = "dropdown" >
- <a class = "dropdown-toggle" id = "dLabel" lub luag haujlwm = "khawm" data-toggle = "dropdown" data-target = "#" href = "/page.html">
- poob
- <b class = "caret" ></b>
- </a>
- <ul class = "dropdown-menu" role = "menu" aria-labeledby = "dLabel" >
- ...
- </ul>
- </div>
Hu rau dropdowns ntawm JavaScript:
- $ ( '.dropdown-toggle' ). poob ( )
Tsis muaj
Programmatic api rau toggling menus rau ib tug muab navbar los yog tabbed navigation.
Lub ScrollSpy plugin yog rau kev hloov kho nav lub hom phiaj raws li txoj haujlwm scroll. Scroll thaj tsam hauv qab ntawm navbar thiab saib cov chav kawm hloov pauv. Lub dropdown sub cov khoom yuav raug highlighted thiab.
Ad leggings keytar, brunch id art party dolor ua haujlwm. Pitchfork yr enim lo-fi ua ntej lawv muag tawm qui. Tumblr ua liaj ua teb-rau- rooj tsheb kauj vab txoj cai txawm li cas los xij. Ntxim hlub cardigan. Velit seitan mcsweeney's photo booth 3 hma hli irure. Cosby sweater lomo jean luv, williamsburg hoodie minim qui koj tej zaum tsis tau hnov txog lawv thiab cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork hwj txwv. Freegan hwj txwv aliqua cupidatat mcsweeney's vero. Cupidatat plaub loko nisi, ea helvetica nulla carles. Tattooed cosby sweater zaub mov tsheb, mcsweeney's quis non freegan vinyl. Lo-fi wes anderson +1 sartorial. Carles tsis zoo nkauj exercitation quis gentrify. Brooklyn adipisicing khoom siv tes ua npias vice keytar deserunt.
Occaecat commodo aliqua delectus. Fap craft npias deserunt skateboard ea. Lomo tsheb kauj vab txoj cai adipisicing banh mi, velit ea sunt tom ntej no locavore single-origin kas fes hauv magna veniam. High life id vinyl, ncho park consequat quis aliquip banh mi pitchfork. Vero VHS yog adipisicing. Consectetur nisi DIY minim tub txib hnab. Cred ex nyob rau hauv, sustainable delectus consectetur fanny pob iphone.
In incididunt echo park, officia deserunt mcsweeney's proident master cleanse thundercats sapiente veniam. Excepteur VHS elit, proident shoreditch +1 biodiesel laborum craft beer. Single-origin coffee wayfarers irure four loko, cupidatat terry richardson master cleanse. Assumenda you probably haven't heard of them art party fanny pack, tattooed nulla cardigan tempor ad. Proident wolf nesciunt sartorial keffiyeh eu banh mi sustainable. Elit wolf voluptate, lo-fi ea portland before they sold out four loko. Locavore enim nostrud mlkshk brooklyn nesciunt.
Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
Keytar twee blog, culpa tub txib hnab marfa txawm delectus zaub mov tsheb. Sapiente synth id assumenda. Locavore sed helvetica cliche irony, thundercats tej zaum koj tsis tau hnov txog lawv ua rau hoodie gluten-dawb lo-fi fap aliquip. Labore elit placeat ua ntej lawv muag tawm, terry richardson proident brunch nesciunt quis cosby sweater pariatur keffiyeh ut helvetica artisan. Cardigan craft npias seitan readymade velit. VHS Chambray Laboris Tempor Veniam. Anim mollit minim commodo ullamco thundercats.
Txhawm rau yooj yim ntxiv tus cwj pwm scrollspy rau koj qhov topbar navigation, tsuas yog ntxiv data-spy="scroll"
rau lub caij koj xav kom neeg soj xyuas rau (feem ntau qhov no yuav yog lub cev) thiab data-target=".navbar"
xaiv qhov twg siv nav. Koj yuav xav siv scrollspy nrog ib .nav
feem.
- <body data-spy = "scroll" data-target = ".navbar" > ... </body>
Hu rau scrollspy ntawm JavaScript:
- $ ( '#navbar' ). scrollspy ()
<a href="#home">home</a>
yuav tsum sib haum mus rau ib yam dab tsi nyob rau hauv lub dom zoo li
<div id="home"></div>
.
Thaum siv scrollspy ua ke nrog kev ntxiv lossis tshem tawm cov ntsiab lus los ntawm DOM, koj yuav tsum hu rau txoj kev hloov tshiab zoo li:
- $ ( '[data-spy="scroll"]' ). txhua ( function () {
- var $spy = $ ( this ). scrollspy ( 'tshiab' )
- });
Cov kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript. Rau cov ntaub ntawv tus cwj pwm, ntxiv rau qhov kev xaiv npe rau data-
, xws li hauv data-offset=""
.
Lub npe | hom | ua ntej | piav qhia |
---|---|---|---|
offset | tus lej | 10 | Pixels rau offset los ntawm sab saum toj thaum xam txoj hauj lwm ntawm scroll. |
Kev tshwm sim | Kev piav qhia |
---|---|
qhib | Qhov xwm txheej no tua hluav taws thaum twg ib yam khoom tshiab tau qhib los ntawm scrollspy. |
Ntxiv ceev, dynamic tab functionality rau kev hloov mus los ntawm panes ntawm cov ntsiab lus hauv zos, txawm tias ntawm dropdown menus.
Raw denim tej zaum koj tsis tau hnov txog lawv cov ris tsho luv Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit neeg tua tsiaj retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, neeg tua tsiaj voluptate nisi qui.
Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.
Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.
Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.
Qhib tabbable tabs ntawm JavaScript (txhua tab yuav tsum tau qhib ib tus zuj zus):
- $ ( '#myTab a' ). nyem ( function ( e ) {
- e . PreventDefault ();
- $ ( qhov no ). tab ( 'show' );
- })
Koj tuaj yeem qhib ib tus neeg tab hauv ntau txoj hauv kev:
- $ ( '#myTab a[href="#profile"]' ). tab ( 'show' ); // Xaiv tab los ntawm lub npe
- $ ( '#myTab a: ua ntej' ). tab ( 'show' ); // Xaiv thawj tab
- $ ( '#myTab a:last' ). tab ( 'show' ); // Xaiv lub tab kawg
- $ ( '#myTab li:eq(2) a' ). tab ( 'show' ); // Xaiv thib peb tab (0-indexed)
Koj tuaj yeem qhib lub tab lossis ntsiav tshuaj navigation yam tsis tau sau ib qho JavaScript los ntawm kev qhia yooj yim data-toggle="tab"
lossis data-toggle="pill"
ntawm lub ntsiab lus. Ntxiv cov nav
thiab nav-tabs
cov chav kawm rau lub tab ul
yuav siv Bootstrap tab styling.
- <ul class = "nav nav-tabs" >
- <li><a href = "#home" data-toggle = "tab"> Tsev </a></li >
- <li><a href = "#profile" data-toggle = "tab"> Profile </a></li >
- <li><a href = "#messages" data-toggle = "tab"> Messages </a></li >
- <li><a href = "#settings" data-toggle = "tab"> Settings </a></li >
- </ul>
Activates lub tab element thiab cov ntsiab lus ntim. Tab yuav tsum muaj ib data-target
lossis ib lub href
hom phiaj rau lub thawv ntim hauv DOM.
- <ul class = "nav nav-tabs" id = "myTab" >
- <li class = "active" ><a href = "#home"> Tsev </a></li >
- <li><a href = "#profile"> Profile </a> </li>
- <li><a href = "#messages"> Messages </a> </li>
- <li><a href = "#settings"> Chaw </a> </li>
- </ul>
- <div class = "tab-content" >
- <div class = "tab-pane active" id = "home" > ... </div>
- <div class = "tab-pane" id = "profile" > ... </div>
- <div class = "tab-pane" id = "messages" > ... </div>
- <div class = "tab-pane" id = "settings" > ... </div>
- </div>
- <script>
- $ ( function () {
- $ ( '#myTab a:last' ). tab ( 'show' );
- })
- </script>
Kev tshwm sim | Kev piav qhia |
---|---|
ua yeeb yam | Qhov kev tshwm sim no tua hluav taws ntawm tab qhia, tab sis ua ntej tab tshiab tau tshwm sim. Siv event.target thiab event.relatedTarget tsom rau lub tab active thiab yav dhau los active tab (yog tias muaj) feem. |
qhia | Qhov xwm txheej no tua hluav taws ntawm tab qhia tom qab tau pom tab. Siv event.target thiab event.relatedTarget tsom rau lub tab active thiab yav dhau los active tab (yog tias muaj) feem. |
- $ ( 'a[data-toggle="tab"]' ). on ( 'qhia' , function ( e ) {
- e . phiaj // activated tab
- e . RelatedTarget // yav dhau los tab
- })
Kev tshoov siab los ntawm qhov zoo tshaj plaws jQuery.tipsy plugin sau los ntawm Jason Frame; Cov lus qhia yog ib qho kev hloov kho tshiab, uas tsis tso siab rau cov duab, siv CSS3 rau cov yeeb yaj kiab, thiab cov ntaub ntawv-tus cwj pwm rau cov npe hauv zos.
Rau cov laj thawj kev ua tau zoo, cov lus qhia thiab cov ntaub ntawv popover-apis yog xaiv rau hauv, txhais tau tias koj yuav tsum pib lawv tus kheej .
Hover tshaj qhov txuas hauv qab no kom pom cov lus qhia:
Tight ris tom ntej no keffiyeh tej zaum koj yuav tsis tau hnov txog lawv. Diam duab lub rooj muag zaub beard raw denim letterpress vegan tub txib hnab stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-ntsis american apparel muaj terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, plaub loko mcsweeney's cleanse vegan chambray. Ib tus kws txawj ntse tiag tiag txawm li cas los xij keytar , scenester ua liaj ua teb-rau- rooj banksy Austin twitter tuav freegan cred nyoos denim ib leeg-hauv paus kas fes kis.
Thaum siv cov lus qhia thiab popovers nrog Bootstrap cov tswv yim pab pawg, koj yuav tau teeb tsa container
(cov ntaub ntawv hauv qab no) kev xaiv kom tsis txhob muaj kev phiv tsis zoo.
Tig lub cuab yeej ntawm JavaScript:
- $ ( '#example' ). tooltip ( Options )
Cov kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript. Rau cov ntaub ntawv tus cwj pwm, ntxiv rau qhov kev xaiv npe rau data-
, xws li hauv data-animation=""
.
Lub npe | hom | ua ntej | piav qhia |
---|---|---|---|
animation | boolean | muaj tseeb | siv css ploj mus rau cov lus qhia |
html | boolean | cuav | Ntxig html rau hauv cov lus qhia. Yog tias tsis tseeb, jquery txoj text kev yuav raug siv los ntxig cov ntsiab lus rau hauv dom. Siv cov ntawv nyeem yog tias koj txhawj xeeb txog XSS tawm tsam. |
tso chaw | hlua | muaj nuj nqi | 'sab saum toj' | yuav ua li cas rau position lub tooltip - sab saum toj | hauv qab | sab laug | txoj cai |
xaiv | txoj hlua | cuav | Yog hais tias muaj ib tug selector, tooltip cov khoom yuav raug delegated rau lub hom phiaj teev. |
lub npe | hlua | muaj nuj nqi | '' | default title value yog 'title' tag tsis nyob |
ua rau | txoj hlua | 'hover focus' | yuav ua li cas tooltip yog triggered - nyem | hover | tsom | phau ntawv. Nco ntsoov tias koj kis tus kab mob sib kis, qhov chaw sib cais, hom kab mob. |
ncua | tus lej | khoom | 0 | ncua kev qhia thiab zais cov lus qhia (ms) - tsis siv rau phau ntawv txhais hom Yog tias muaj tus lej nkag, ncua sijhawm yog siv rau ob qho tib si zais / qhia Object structure yog: |
thawv | hlua | cuav | cuav | Appends lub tooltip rau ib lub caij tshwj xeeb |
- <a href = "#" data-toggle = "tooltip" title = "thawj tooltip" > hover over me </a>
Txuas tus tooltip handler rau ib qho khoom sau.
Qhia ib lub ntsiab lus qhia.
- $ ( '#element' ). tooltip ( 'show' )
Hide ib lub ntsiab lus qhia.
- $ ( '#element' ). tooltip ( 'Hide' )
Toggles ib lub ntsiab lus qhia.
- $ ( '#element' ). tooltip ( 'toggle' )
Nias thiab rhuav tshem cov ntsiab lus ntawm cov cuab yeej.
- $ ( '#element' ). tooltip ( 'ua kom puas' )
Ntxiv me me ntawm cov ntsiab lus, zoo li cov hauv iPad, rau txhua lub hauv paus rau cov ntaub ntawv thib ob hauv tsev. Hover tshaj lub khawm kom ua rau lub popover. Yuav tsum muaj Tooltip kom suav nrog.
Plaub txoj kev xaiv muaj: sab saum toj, sab xis, hauv qab, thiab sab laug dlhos.
Sed posuere consectetur yog nyob rau hauv lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Sed posuere consectetur yog nyob rau hauv lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Sed posuere consectetur yog nyob rau hauv lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Sed posuere consectetur yog nyob rau hauv lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Tsis muaj qhov cim qhia tias popovers yog tsim los ntawm JavaScript thiab cov ntsiab lus hauv tus data
cwj pwm.
Qhib popovers ntawm JavaScript:
- $ ( '#example' ). popover ( kev xaiv )
Cov kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript. Rau cov ntaub ntawv tus cwj pwm, ntxiv rau qhov kev xaiv npe rau data-
, xws li hauv data-animation=""
.
Lub npe | hom | ua ntej | piav qhia |
---|---|---|---|
animation | boolean | muaj tseeb | siv css ploj mus rau cov lus qhia |
html | boolean | cuav | Ntxig html rau hauv popover. Yog tias tsis tseeb, jquery txoj text kev yuav raug siv los ntxig cov ntsiab lus rau hauv dom. Siv cov ntawv nyeem yog tias koj txhawj xeeb txog XSS tawm tsam. |
tso chaw | hlua | muaj nuj nqi | 'txoj cai' | yuav ua li cas tso lub popover - saum | hauv qab | sab laug | txoj cai |
xaiv | txoj hlua | cuav | Yog hais tias muaj ib tug selector, tooltip cov khoom yuav raug delegated rau lub hom phiaj |
ua rau | txoj hlua | 'nias' | yuav ua li cas popover yog triggered - nyem | hover | tsom | phau ntawv |
lub npe | hlua | muaj nuj nqi | '' | default title value yog 'title' attribute tsis nyob |
cov ntsiab lus | hlua | muaj nuj nqi | '' | default ntsiab lus tus nqi yog 'cov ntaub ntawv-cov ntsiab lus' tus cwj pwm tsis nyob |
ncua | tus lej | khoom | 0 | ncua kev qhia thiab zais qhov popover (ms) - tsis siv rau phau ntawv txhais hom Yog tias muaj tus lej nkag, ncua sijhawm yog siv rau ob qho tib si zais / qhia Object structure yog: |
thawv | hlua | cuav | cuav | Appends lub popover rau ib yam khoom |
Rau kev ua tau zoo vim li cas, Tooltip thiab Popover cov ntaub ntawv-apis yog xaiv rau hauv. Yog tias koj xav siv lawv tsuas yog qhia qhov kev xaiv xaiv.
Initializes popovers rau ib qho khoom sau.
Tshaj tawm cov ntsiab lus popover.
- $ ( '#element' ). popover ( 'show' )
Hide cov ntsiab lus popover.
- $ ( '#element' ). popover ( 'hide' )
Toggles lub ntsiab lus popover.
- $ ( '#element' ). popover ( 'toggle' )
Nias thiab rhuav tshem lub ntsiab lus popover.
- $ ( '#element' ). popover ( 'ua kom puas' )
Ntxiv tso tawm haujlwm rau tag nrho cov lus ceeb toom nrog cov plugin no.
Hloov qhov no thiab qhov ntawd thiab sim dua. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus zaum amet fermentum.
Pab kom tshem tawm kev ceeb toom ntawm JavaScript:
- $ ( ".alert" ). ceeb toom ( )
Tsuas yog ntxiv data-dismiss="alert"
rau koj lub khawm kaw kom tau txais kev ceeb toom kaw ua haujlwm.
- <a class = "kaw" data-dismiss = "alert" href = "#" > × </a>
Wraps tag nrho cov lus ceeb toom nrog ze functionality. Txhawm rau kom koj cov lus ceeb toom tawm thaum kaw, xyuas kom lawv muaj cov chav kawm .fade
thiab .in
cov chav kawm twb tau thov rau lawv.
Kaw ceeb toom.
- $ ( ".alert" ). ceeb toom ( 'kaw' )
Bootstrap's alert class exposes ob peb txheej xwm rau hooking rau hauv alert functionality.
Kev tshwm sim | Kev piav qhia |
---|---|
kaw | Qhov xwm txheej no tua hluav taws tam sim ntawd thaum close hu ua piv txwv. |
kaw | Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub ceeb toom tau raug kaw (yuav tos rau css kev hloov pauv kom tiav). |
- $ ( '#my-alert' ). khi ( 'kaw' , ua haujlwm () {
- // ua ib yam dab tsi…
- })
Tau txais cov qauv tsim thiab hloov pauv hloov pauv rau cov khoom sib tsoo zoo li accordions thiab navigation.
* Yuav tsum muaj Transitions plugin kom suav nrog.
Siv lub cev qhuav dej, peb tsim ib qho yooj yim accordion style widget:
- <div class = "accordion" id = "accordion2" >
- <div class = "accordion-group" >
- <div class = "accordion-heading" >
- <a class = "accordion-toggle" data-toggle = "collapse" data-parent = "#accordion2" href = "#collapseOne" >
- Collapsible Group Yam #1
- </a>
- </div>
- <div id = "collapseOne" class = "accordion-lub cev poob rau hauv" >
- <div class = "accordion-inner" >
- Dab neeg poj ntxoog...
- </div>
- </div>
- </div>
- <div class = "accordion-group" >
- <div class = "accordion-heading" >
- <a class = "accordion-toggle" data-toggle = "collapse" data-parent = "#accordion2" href = "#collapseTwo" >
- Collapsible Group Yam #2
- </a>
- </div>
- <div id = "collapseTwo" class = "accordion-lub cev ploj" >
- <div class = "accordion-inner" >
- Dab neeg poj ntxoog...
- </div>
- </div>
- </div>
- </div>
- ...
Koj tuaj yeem siv lub plugin yam tsis muaj accordion markup. Ua ib lub pob toggle lub expanding thiab collapsing ntawm lwm lub caij.
- <khawm hom = "button" class = "btn btn-danger" data-toggle = "collapse" data-target = "#demo" >
- yooj yim collapsible
- </button>
- <div id = "demo" class = "collapse in" > … </div>
Tsuas yog ntxiv data-toggle="collapse"
thiab ib qho data-target
rau lub caij kom tau txais kev tswj hwm ntawm lub caij collapsible. Tus data-target
cwj pwm lees txais css xaiv los siv lub cev qhuav dej rau. Nco ntsoov ntxiv cov chav kawm collapse
rau lub caij collapsible. Yog tias koj xav kom nws qhib lub neej ntawd, ntxiv cov chav kawm ntxiv in
.
Txhawm rau ntxiv accordion-zoo li pawg tswj hwm rau kev tswj hwm, ntxiv cov ntaub ntawv tus cwj pwm data-parent="#selector"
. Xa mus rau qhov demo kom pom qhov no hauv kev nqis tes ua.
Qhib manually nrog:
- $ ( ".collapse" ). poob ( )
Cov kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript. Rau cov ntaub ntawv tus cwj pwm, ntxiv rau qhov kev xaiv npe rau data-
, xws li hauv data-parent=""
.
Lub npe | hom | ua ntej | piav qhia |
---|---|---|---|
niam txiv | xaiv | cuav | Yog tias selector ces tag nrho cov ntsiab lus collapsible nyob rau hauv cov niam txiv uas tau teev tseg yuav raug kaw thaum cov khoom no collapsible tshwm sim. (zoo ib yam li kev coj cwj pwm accordion) |
toggle | boolean | muaj tseeb | Toggles lub caij collapsible ntawm invocation |
Activates koj cov ntsiab lus raws li lub ntsiab collapsible. Txais ib qho kev xaiv xaiv object
.
- $ ( '#myCollapsible' ). ploj ({
- toggle : cuav
- })
Toggles lub caij collapsible kom pom los yog zais.
Qhia ib lub caij collapsible.
Hide ib lub caij collapsible.
Bootstrap's collapse class exposes ob peb txheej xwm rau hooking mus rau hauv vau functionality.
Kev tshwm sim | Kev piav qhia |
---|---|
ua yeeb yam | Qhov xwm txheej no tua hluav taws tam sim ntawd thaum show hu ua piv txwv. |
qhia | Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub caij sib tsoo tau ua kom pom rau tus neeg siv (yuav tos rau css kev hloov pauv kom tiav). |
zais | Qhov kev tshwm sim no raug rho tawm haujlwm tam sim ntawd thaum hide hu ua txoj kev. |
zais cia | Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub caij sib tsoo tau muab zais los ntawm tus neeg siv (yuav tos rau css kev hloov pauv kom tiav). |
- $ ( '#myCollapsible' ). ntawm ( 'hidden' , function () {
- // ua ib yam dab tsi…
- })
Cov slideshow hauv qab no qhia tau hais tias ib tug generic plugin thiab tivthaiv rau cycling los ntawm lub ntsiab zoo li ib tug carousel.
- <div id = "myCarousel" class = "carousel swb" >
- <ol class = "carousel-indicators" >
- <li data-target = "#myCarousel" data-slide-to = "0" class = "active" ></li>
- <li data-target = "#myCarousel" data-slide-to = "1" ></li>
- <li data-target = "#myCarousel" data-slide-to = "2" ></li>
- </ol>
- <!-- Carousel khoom -->
- <div class = "carousel-inner" >
- <div class = "active item" > … </div>
- <div class = "item" > … </div>
- <div class = "item" > … </div>
- </div>
- <!-- Carousel nav -->
- <a class = "carousel-control left" href = "#myCarousel" data-slide = "prev" > ‹ </a>
- <a class = "carousel-tswj txoj cai" href = "#myCarousel" data-slide = "tom ntej" > › </a>
- </div>
Siv cov ntaub ntawv cwj pwm kom yooj yim tswj txoj hauj lwm ntawm lub carousel. data-slide
lees txais cov lus tseem ceeb prev
lossis next
, uas hloov txoj haujlwm swb txheeb ze rau nws txoj haujlwm tam sim no. Xwb, siv data-slide-to
kom dhau qhov ntsuas qhov ntsuas tsis tau rau lub carousel data-slide-to="2"
, uas dhia yog qhov swb mus rau qhov ntsuas tshwj xeeb pib nrog 0
.
Hu rau carousel manually nrog:
- $ ( '.carousel' ). carousel ()
Cov kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScriptz. Rau cov ntaub ntawv tus cwj pwm, ntxiv rau qhov kev xaiv npe rau data-
, xws li hauv data-interval=""
.
Lub npe | hom | ua ntej | piav qhia |
---|---|---|---|
lub sijhawm | tus lej | 5000 | Lub sijhawm ncua sijhawm ntawm kev caij tsheb kauj vab ib yam khoom. Yog hais tias tsis tseeb, carousel yuav tsis cia li voj voog. |
nres | txoj hlua | "hover" | Pauses kev caij tsheb kauj vab ntawm lub carousel ntawm mouseenter thiab rov pib caij tsheb kauj vab ntawm lub carousel ntawm mouseleave. |
Pib lub carousel nrog ib qho kev xaiv xaiv object
thiab pib caij tsheb kauj vab los ntawm cov khoom.
- $ ( '.carousel' ). carousel ({
- Lub sijhawm : 2000
- })
Cycles los ntawm cov khoom carousel ntawm sab laug mus rau sab xis.
Nres lub carousel los ntawm kev caij tsheb kauj vab los ntawm cov khoom.
Cycles lub carousel rau ib lub thav duab tshwj xeeb (0 raws, zoo ib yam li ib qho array).
Lub voj voog mus rau qhov khoom dhau los.
Cycles mus rau yam khoom tom ntej.
Bootstrap's carousel class exposes ob txheej xwm rau hooking rau hauv carousel functionality.
Kev tshwm sim | Kev piav qhia |
---|---|
swb | Qhov xwm txheej no tua hluav taws tam sim ntawd thaum tus slide txheej txheem piv txwv raug hu. |
swb | Qhov kev tshwm sim no raug rho tawm haujlwm thaum lub carousel tau ua tiav nws txoj kev hloov pauv. |
Ib qho yooj yim, yooj yim txuas ntxiv plugin rau sai sai tsim elegant typeaheads nrog rau cov ntawv sau ntawv nkag.
- <input type = "text" data-provide = "typeahead" >
Koj yuav xav teem caij autocomplete="off"
los tiv thaiv cov ntawv qhia zaub mov tsis zoo los ntawm qhov tshwm sim ntawm Bootstrap typeahead dropdown.
Ntxiv cov ntaub ntawv tus cwj pwm los sau npe ib lub caij nrog typeahead functionality raws li qhia hauv qhov piv txwv saum toj no.
Hu rau typeahead manually nrog:
- $ ( '.typeahead' ). ntaus ntawv ( )
Cov kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript. Rau cov ntaub ntawv tus cwj pwm, ntxiv rau qhov kev xaiv npe rau data-
, xws li hauv data-source=""
.
Lub npe | hom | ua ntej | piav qhia |
---|---|---|---|
qhov chaw | array, ua haujlwm | [] | Cov ntaub ntawv los nug tawm tsam. Tej zaum yuav yog ib qho array ntawm cov hlua los yog kev ua haujlwm. Qhov kev ua haujlwm tau dhau ob qhov kev sib cav, tus query nqi hauv qhov chaw nkag thiab process hu rov qab. Kev ua haujlwm yuav raug siv synchronously los ntawm kev xa rov qab cov ntaub ntawv ncaj qha lossis asynchronously ntawm kev process hu rov qab qhov kev sib cav. |
cov khoom | tus lej | 8 | Tus naj npawb max ntawm cov khoom los tso saib hauv qhov poob. |
minLength | tus lej | 1 | Yam tsawg kawg nkaus qhov ntev uas yuav tsum tau ua ua ntej ua kom tiav cov lus qhia autocomplete |
tus sib tw | muaj nuj nqi | cas insensitive | Txoj kev siv los txiav txim siab seb qhov lus nug puas phim ib yam khoom. Txais ib qho kev sib cav, qhov item tawm tsam uas yuav sim cov lus nug. Nkag mus rau cov lus nug tam sim no nrog this.query . Rov qab ib qho boolean true yog tias cov lus nug yog qhov sib tw. |
tus txheej txheem | muaj nuj nqi | qhov tseeb match, case sensitive, case insensitive |
Txoj kev siv los txheeb cov txiaj ntsig autocomplete. Txais ib qho kev sib cav items thiab muaj lub peev xwm ntawm qhov piv txwv typeahead. Siv cov lus nug tam sim no nrog this.query . |
hloov tshiab | muaj nuj nqi | rov qab cov khoom xaiv | Txoj kev siv los xa cov khoom xaiv. Txais ib qho kev sib cav, item thiab muaj lub peev xwm ntawm qhov piv txwv typeahead. |
highlighter | muaj nuj nqi | highlights tag nrho cov default match | Txoj kev siv los qhia txog cov txiaj ntsig autocomplete. Txais ib qho kev sib cav item thiab muaj lub peev xwm ntawm qhov piv txwv typeahead. Yuav tsum rov html. |
Initializes ib tug input nrog ib tug typeahead.
Lub subnavigation nyob rau sab laug yog ib tug nyob demo ntawm affix plugin.
Txhawm rau yooj yim ntxiv affix cwj pwm rau txhua lub caij, tsuas yog ntxiv data-spy="affix"
rau lub caij koj xav soj ntsuam. Tom qab ntawd siv offsets los txhais thaum twg los hloov lub pinning ntawm ib lub caij rau thiab tawm.
- <div data-spy = "affix" data-offset-top = "200" > ... </div>
affix
,
affix-top
, thiab
affix-bottom
. Nco ntsoov xyuas cov niam txiv uas muaj feem cuam tshuam thaum lub affix kicks nyob rau hauv raws li nws yog tshem tawm cov ntsiab lus los ntawm qhov ib txwm ntws ntawm nplooj ntawv.
Hu rau affix plugin ntawm JavaScript:
- $ ( '#navbar' ). affix ( )
Cov kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript. Rau cov ntaub ntawv tus cwj pwm, ntxiv rau qhov kev xaiv npe rau data-
, xws li hauv data-offset-top="200"
.
Lub npe | hom | ua ntej | piav qhia |
---|---|---|---|
offset | tus lej | muaj nuj nqi | khoom | 10 | Pixels rau offset los ntawm kev tshuaj ntsuam thaum xam txoj hauj lwm ntawm scroll. Yog tias muab ib tus lej, qhov offset yuav raug siv rau ob qho tib si sab saum toj thiab sab laug. Txhawm rau mloog rau ib qho kev taw qhia, lossis ntau qhov txawv txav, tsuas yog muab ib qho khoom offset: { x: 10 } . Siv ib qho kev ua haujlwm thaum koj xav tau dynamically muab qhov offset (pab tau rau qee qhov qauv tsim). |