-
Notifications
You must be signed in to change notification settings - Fork 2
/
JQ.html
773 lines (649 loc) · 26.7 KB
/
JQ.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
<!-- JQUERY - Javascript Library - by Beumsk -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>JQuery</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script><!--jQuery library; always before js files-->
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script><!--IU jQuery for better animations-->
<!--Best way is to write JQuery in an external js file but for a better view, i will combine in one here-->
<!--JQuery has 2 models: one for developement and one for online version (.min)-->
<!--JQuery must always be inside <script> and starting with $(function() {}); or $(document).ready(function() {}); -->
<script>
//start of the script
$(function() { // always the beginning of jquery code
});
// JQuery filters
$("p") // selects all p
$(".class") // selects class named 'class'
$("#id") // selects id named 'id'
$(this) // selects same selector as function
$(this).find("p") // selects p in function
$("p").next() // selects selector right after "p"; very useful with this
$("p:first") // selects first p; last works too
$("p:eq(1)") // selects second p; works as an array
$("p:gt(0)") // selects p greater than 0
$("p:lt(3)") // selects p lower than 3
$("p:even") // selects p even (first element is 0 !)
$("p:odd") // selects p odd (first element is 0 !);
$("p:not('.main')") // selects p without 'main' class
// more filters
$("p:hidden") // selects p hidden
$("p:visible") // selects p visible
$(":input") // all input type forms (input, textarea, button, etc)
$(":header") // h1 to h6 tags
$("p:contains('text')") // selects p with 'text'
$("p:has('element')") // selects p with 'element' as element
$("[align]") // selects elements with align attribut
$("[align='center']") // selects elements with align center
$("[align!='center']") // selects elements without align center
$("[src^='he']") // selects elements with src starting with 'he'
$("[src$='llo']") // selects elements with src ending with "llo"
$("input[name='lol']") // selects input elements with name lol
$("[href='#home']") // selects elements with #home href
// switch from js var to jquery var
var variableJS = "anything";
var variableJQ = $(variableJS);
// create
$("<p>"); // creates p tag (or anything else); need to append it later
$("<p>Hello</p>"); // creates a p tag with text 'Hello'; need to append it later
$("<p class='justify'>Hello</p>"); // creates a p tag with text 'Hello'and class '.justify'; need to append it later
$("<p>", { // other way to create this element; need to append it later anyway
html: "Hello",
"class": "justify"
});
var a = $([]); // create empty jquery object
// switch from jquery object to js object
var divs = $("div").get();
// input
$("input").val(); // get input value
$("input[id='name']").val(); // get input id="name" value
$("input").val("John"); // set John as new input value
// effect methods
$("p").show(1000, "linear"); // show element
$("p").hide(1000, "linear"); // hide element
$("p").toggle(1000, "linear"); // show/hide element
$("p").fadeIn(1000, "linear"); // fade element in
$("p").fadeOut(1000, "linear"); // fade element out
$("p").fadeToggle(1000, "linear"); // switch between fadeIn and fadeOut
$("p").fadeTo(1000, 0.5); // fade element to some opacity; speed and opacity as paramters
$("p").toggleClass("oldClass newClass"); // switch between oldClass and newClass for every event
$("p").slideUp(1000, "linear"); // hide element uping
$("p").slideDown(1000, "linear"); // hide element downing
$("p").slideToggle(1000, "linear"); // hide element same position
$("button").prop("disabled", "true"); // disables button
$("p").fadeIn().delay(2000).fadeOut(); // fadeIn hen fadeOut after 2sec
// animate
$("p").animate({left:"+=10px"}, 500, "linear"); // animates p to 10px to the right
$("p").animate({left:"+=10px"}, 500, "linear", function() {}); // the function will be executed after the animation
$("p").animate({left:"+=10px", top:"+=10px"}, 1000); // multiple animations at the same time
$("p").animate({left:"+=10px"}, 1000).animate({top:"+=10px"}, 1000); // multiple animations one after another
$("p").animate({left:"+=10px"}, {duration:500, queue: true}); // other syntax allowing queues, (effective to vary duration of animations)
$("p").stop(); // stop currently running animation
$("p").stop(false, false); // first boolean manage queue erasement and second manages the final statement
function bis() { $("p").animate({left:"+=10px"}, 500, bis); }; bis(); // never-ending animation
// manipulation methods
$("p").css("color", "red"); // change css of p
$("p").html("Hey <span>Red</span> !"); // replace content of first p with html tags understood
$("p").text("Hey Red !"); // replace text of p without tags understood
$("p").replaceWith("<p>Hey Red !</p>"); // replace entirely p
$("p").remove(); // remove p and children
$("p").empty(); // remove everything inside p
$("p").before("Content"); // move content before p
$("p").after("Content"); // move content after p
$("p").prepend("Content"); // move inside p (after opening tag)
$("p").append("Content"); // move inside p (before closing tag)
$("p").prependTo("div"); // insert p in div (after opening tag)
$("p").appendTo("div"); // insert p in div (before closing tag)
$("p").insertBefore("div"); // insert p before div
$("p").insertAfter("div"); // insert p after div
$("p").wrap("<i></i>"); // wrap p with i tags
$("p").wrapInner("<i></i>"); // wrap with i tags inside p tag
$("a").attr("href", "http://somewhere.lol"); // add attribut and value; removeAttr() too
$("p").addClass("class1 class2"); // add one or multiple class
$("p").removeClass("class1 class2"); // remove one or multiple class
$("p").toggleClass("class1 class2"); // switch between class
$("p").hasClass("class1"); // return true if p has class1
$("p").is(".class1"); // return true if p has class1; possible with all selectors
$("p").clone().appendTo("div"); // clone p and insert inside in div (before closing tag; there will be 2 times the same p
location.reload(); // reload page
// DOM traversing
$("p").children(); // access all direct children
$("p").find("span"); // access to all span inside p
$("p").parent(); // access direct parent
$("p").parents(); // access all parents elements
$("p").parentsUntil("section"); // access all elements until 'section'
$("p").closest("div"); // similar to parent except that it takes only one element matching
$("p").siblings(); // access siblings (tag on same level)
$("p").next(); // access next siblings (tag on same level)
$("p").prev(); // access previous siblings (tag on same level)
$("div p").first(); // access first p inside div
$("div p").last(); // access last p inside div
$("p").eq(0); // access first p
$("p").filter(".info"); // access all p with info class
$("p").not(".info"); // access all p without info class
$("p:nth-child(3)"); // access to third child
// Size and position
$("p").offset().left; // position absolute of p from left; .right
$("p").offset().top; // position absolute of p from top; .bottom
$("p").offset({top: 100, left: 100}); // set position absolute;
$("p").position().right; // position relative of p from right; .left
$("p").position().bottom; // position relative of p from bottom; .top
$("p").height(); // basic height (no margins, paddings and borders)
$("p").innerHeight(); // height + paddings
$("p").outerHeight(); // height + paddings + borders
$("p").outerHeight(true); // height + paddings + borders + margins
$("p").width(); // basic width (no margins, paddings and borders)
$("p").innerWidth(); // width + paddings
$("p").outerWidth(); // width + paddings + borders
$("p").outerWidth(true); // width + paddings + borders + margins
// events
$("p").on("click", function() {}); // if click; dblclick too
$("p").on("scroll", function() {}); // if scroll on an element
$("p").on("mouseover", function() {}); // if mouse enter element
$("p").on("mouseenter", function() {}); // if mouse enter element
$("p").on("mouseleave", function() {}); // if mouse leave element
$("p").on("mouseout", function() {}); // if mouse leave element
$("p").on("mousedown", function() {}); // if you press on mouse on an element
$("p").on("mouseup", function() {}); // if you stop pressing on mouse on an element
$("p").on("keydown", function() {}); // if you press a key on your keyboard; each key has a number to select it
$("p").on("keyup", function() {}); // if you stop pressing a key
$("p").on("keypress", function() {}); // if you keep on pressing a key
$(window).on("resize", function() {}); // if window is resized
$("input").on("focus", function() {}); // if field gets focus
$("input").on("blur", function() {}); // if field loses focus
$("input").on("change", function() {}); // when input, textarea or select value is changed
$(window).on("load", function() {}); // when everything is loaded on page
$(window).on("unload", function() {}); // when you quit the current page
$("p").on("mouseover mouseenter", function() {}); // multiple event in one line
$("p").off(); // remove all event handlers of p
$("p").off("click", functionName); // remove functionName event of p
$("p").on("click.namespace", function() {}); // namespaces works like css classes;
$("p").off("click.namespace"); // will switch off event for this namespace only
$("p").one("click", function() {}); // event only works first time
$("p").trigger("click"); // useful to trigger an event from another element; some events are not triggerable (load, mouse, resize)
$("p").on("personalised", function() {}); // create personalised event
$("p").trigger("personalised"); // trigger your personalised event
$("p").on("click", "span", function() {}); // event delegation; from p to span tags
$("p").off("click", "span"); // remove event delegation
// queue
var myQueue = $("p").queue(); // return an array of queued animations for p
varqueueLength = $("p").queue().length; // return length of queue
$("p").queue(function() {}); // add animations to the queue
$("p").dequeue(); // play and removes animation from the queue
$("p").clearQueue(); // clears the queue
// text methods
$.trim(" Hello "); // remove extern spaces "Hello"
"Hello".charAt(1); // "e"
$("div:contains('hello')"); // selects div containing 'hello'
$("div").replaceWith("<p>Hola</p>"); // replace div content
$("div").replaceWith("#replacer"); // deletes div and moves #replacer to the div location
// array methods
var myArray = ["html", "css", "js"];
myArray.join(", "); // "html, css, js"
$.grep(myArray, function(el, ind) { // 'js'
return (el != "css" && ind > 0); // checker
}, false); // inverse checker if true
$.map(myArray, function(el, ind) { // 1-->html, 2-->css, 3-->js
return (ind + "-->" + el.toUpperCase());
});
$.inArray("js", myArray, 0); // 2; returns index; 3d parameters is the start of the search (if 0, search the whole array)
var yourArray = ["jq", "bs"];
$.merge(myArray, yourArray); // myArray -> html, css, js, jq, bs
// iterate with jquery
$("p").each(function(index, elem) {
$(elem).prepend(index + ": ");
});
// type and which event
$("#target").on("event", function(e){
console.log("Event : " + e.type + ". Button pressed : " + e.which );
});
// switch on and off an event
function switchh() {
alert("Image cliquée");
}
$("#on").on("click", function() {
$("img").click(switchh);
});
$("#off").on("click", function() {
$("img").off("click", switchh);
});
// disable/enable button event; only works with button tag
$("#ok").on("click", function() {
$(this).animate({width:"+=50px"}, 1000);
});
$("#off").on("click", function() {
$("#ok").attr("disabled", "disabled");
});
$("#on").on("click", function() {
$("#ok").removeAttr("disabled");
});
// remove jquery animations
$("p").on("click", function() {
jQuery.fx.off = true;
});
// swap elements place in DOM
function swapElts(elt1, elt2) {
var $temp = $("<div>");
elt1.before($temp);
elt2.before(elt1);
$temp.before(elt2);
$temp.remove;
}
// show/hide one after the other
$(function() {
$("#affiche").click(function() {
$("img").first().show("slow", function showNextOne() {
$(this).next("img").show("slow", showNextOne);
});
});
$("#cache").click(function() {
$("img").first().hide("slow", function hideNextOne() {
$(this).next("img").hide("slow", hideNextOne);
});
});
});
// change opacity when mouse enters/leaves
$(document).ready(function() {
$("div").mouseenter(function() {
$("div").fadeTo("fast", 1);
});
$("div").mouseleave(function() {
$("div").fadeTo("fast", 0.5);
});
});
// toggle between two classes; can easily modify css of an object
$("div").on("click", function() {
$(this).toggleClass("newClass");
});
// use this to have action only on the div clicked and not all the div
$(document).ready(function() {
$("div").click(function() {
$(this).fadeOut("slow");
});
});
// show .panel toggle
$(document).ready(function() {
$(".pull-me").click(function() {
$(".panel").slideToggle("slow");
});
});
// thanks to the variable, the p moves and does not stand in the first place; no need to delete afterwards
$(document).ready(function() {
var $paragraphe = $("<p>mdr</p>");
$("#un").after($paragraphe);
$("#deux").after($paragraphe);
});
// reset form values
function resetForm() {
$(":input").not(":button, :reset, :submit, :hidden").val("").prop("checked", false).prop("selected", false);
}
// get value from a form
$(document).ready(function () { // will add what you type in form
$("#button").click(function () {
var toAdd = $("input[name='message']").val(); // get the value of the input tag 'name=mesage'
$("#destination").append("<p>" + toAdd + "</p>") // append the message in a p tag
});
});
// little trick; we would use a div instead of a button, to prevent the page to reload
// hover adding class and removing after
$(document).ready(function() {
$("div").hover( // can have to functions separated by a coma; what to do when hover, and what to do after
function() {
$(this).addClass("miseenvaleur");
},
function() {
$(this).removeClass("miseenvaleur");
}
);
});
// validate form with enter without page refresh
$("input").keypress(function (e) {
if (e.which == 13) {
e.preventDefault();
$("#button").click();
}
});
// code to let you move image in the 4 directions
$(document).ready(function() {
$(document).keydown(function(key) {
switch(parseInt(key.which,10)) {
// left arrow pressed
case 37:
$("img").animate({left: "-=10px"}, "fast");
break;
// up arrow pressed
case 38:
$("img").animate({top: "-=10px"}, "fast");
break;
// right arrow pressed
case 39:
$("img").animate({left: "+=10px"}, "fast");
break;
// down arrow pressed
case 40:
$("img").animate({top: "+=10px"}, "fast");
break;
}
});
});
// better animation thanks to IU jQuery
$(document).ready(function() {
$("div").click(function() {
$("div").effect("explode"); // exploses
});
});
// better animation thanks to IU jQuery
$(document).ready(function() {
$("div").click(function() {
$("div").effect("bounce", {times:3}, 200); // bounces
});
});
// better animation thanks to IU jQuery
$(document).ready(function() {
$("div").click(function() {
$("div").effect("slide"); // slides to become visible
});
});
// better animation thanks to IU jQuery
$(document).ready(function() {
$("div").draggable(); // drag and drop div
});
// better animation thanks to IU jQuery
$(document).ready(function() {
$("div").resizable(); // resize div
});
// better animation thanks to IU jQuery
$(document).ready(function() {
$("div").sortable(); // reorders a list
});
// better animation thanks to IU jQuery
$(document).ready(function() {
$("div").accordion(); // creates an accordion from titles and div
});
// a is an object which selects all "div" tags
$(function() {
var a = $("div");
});
// add 'my_class' class to all "img" elements
$(function() {
$("img").addClass("my_class");
});
// change properties of '#el'
$(function() {
$("#el").css("background-color", "red").fadeIn("slow");
});
// code will process when clicking on '#action'
$(function() {
$("#action").click(function() {
/*my code*/
});
});
// menu closing on click outside
$("html").click(function() {
// Hide the menus if visible here
$(".menu").hide();
});
$("#menucontainer").click(function(event){
event.stopPropagation();
// show menu here
$(".menu").toggle();
});
// AJAX
jQuery.getJSON( "url.com", "data", function(response) {
// process the response
});
</script>
<!--display "#item" on click-->
<a>Click</a>
<p id="item">Hidden message</p>
<script>
$(function() {
$("a").click(function() {
$("#item").collapse("toggle");
});
});
</script>
<!--display "#item" on click and a pop-up-->
<a>Click</a>
<p id="item">Hidden message</p>
<script>
$(function() {
$("a").click(function() {
$("#item").collapse("toggle");
});
$("#item").on("shown.bs.collapse", function() {
alert("On me voit !");
});
});
</script>
<!--dropdown button; need data-toggle on 'h1' to work-->
<div class="btn-group">
<h1 data-toggle="dropdown"><span class="label label-default">Pass on me !</span></h1>
<ul class="dropdown-menu">
<li><a href="#">Petters</a></li>
<li><a href="#">Zoos</a></li>
<li><a href="#">Hunters</a></li>
</ul>
</div>
<script>
$(function() {
$("h1").mouseover(function() {
$(this).dropdown("toggle");
});
});
</script>
<!--Modal windows; need '#info' tags and html files-->
<div class="container">
<div class="btn-group">
<button id="page1" type="button" class="btn btn-primary">Page 1</button>
<button id="page2" type="button" class="btn btn-primary">Page 2</button>
<button id="page3" type="button" class="btn btn-primary">Page 3</button>
</div>
<div class="modal fade" id="infos">
<div class="modal-dialog">
<div class="modal-content"></div>
</div>
</div>
</div>
<script>
$(function() {
$("body").on("hidden.bs.modal", ".modal", function () { // helps to reinitialise; otherwise the smae pages opens on and on
$(this).removeData("bs.modal");
});
$("#page1").click(function() {
$("#infos").modal({ remote: "remote1.html" } ,"show");
});
$("#page2").click(function() {
$("#infos").modal({ remote: "remote2.html" }, "show");
});
$("#page3").click(function() {
$("#infos").modal({ remote: "remote3.html" }, "show");
});
});
</script>
<!--Basic modal window-->
<button class="btn btn-primary">Informations</button>
<div class="modal" id="infos">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">x</button>
<h4 class="modal-title">More information</h4>
</div>
<div class="modal-body">
The tiger is an animal...
</div>
<div class="modal-footer">
<button class="btn btn-info" data-dismiss="modal">Fermer</button>
</div>
</div>
</div>
</div>
<script>
$(function() {
$(".btn").click(function() {
$(".modal").modal("show");
});
});
</script>
<!--Tab-->
<ul class="nav nav-pills nav-justified">
<li><a href="#accueil">Home</a></li>
<li class="active"><a href="#livres">Books</a></li>
<li><a href="#temoignages">witness</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane" id="accueil">Home text</div>
<div class="tab-pane" id="temoignages">All witnesses</div>
<div class="tab-pane active" id="livres">All books</div>
</div>
<script>
$(function() {
$("a").click(function(e) {
e.preventDefault();
$(this).tab("show");
});
});
</script>
<!--Waiting button-->
<a class="btn btn-primary" data-loading-text="Chargement...">Cliquez !</a>
<script>
$(function (){
$("a").click(function () {
with($(this)) {
button("loading");
setTimeout(function () {
button("reset");
}, 4000);
}
})
});
</script>
<!--Carousel with commands and status-->
<div class="container">
<div class="row">
<div class="col-lg-offset-2 col-lg-8">
<div id="carousel" class="carousel slide">
<div class="carousel-inner">
<div class="item active"><img alt="" src="http://fraisfrais.com/wp-content/uploads/2016/01/alexis-ren-2.jpg"></div>
<div class="item"><img alt="" src="http://i.dailymail.co.uk/i/pix/2016/03/17/20/324CAFAD00000578-3497508-image-a-64_1458245250690.jpg"></div>
<div class="item"><img alt="" src="http://www.worn.cz/public/files/07b/123793-1208380_262336840582186_2084814618_n.jpg"></div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-success" id="first">
<input type="radio" name="options"><span class="glyphicon glyphicon-fast-backward"></span>
</label>
<label class="btn btn-success" id="previous">
<input type="radio" name="options"><span class="glyphicon glyphicon-step-backward"></span>
</label>
<label class="btn btn-success" id="pause">
<input type="radio" name="options"><span class="glyphicon glyphicon-pause"></span>
</label>
<label class="btn btn-success active" id="play">
<input type="radio" name="options"><span class="glyphicon glyphicon-play"></span>
</label>
<label class="btn btn-success" id="next">
<input type="radio" name="options"><span class="glyphicon glyphicon-step-forward"></span>
</label>
<label class="btn btn-success" id="last">
<input type="radio" name="options"><span class="glyphicon glyphicon-fast-forward"></span>
</label>
</div>
<p><span class="label label-info"></span></p>
</div>
</div>
</div>
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script>
function affichage() {
var total = $(".item").length;
var current = $(".item.active").index() + 1;
$(".label").text(current + " / "+ total);
}
$(function () {
affichage();
$(".carousel").carousel({ interval: 2000 });
$("#first").click(function() { $(".carousel").carousel(0); });
$("#previous").click(function() { $(".carousel").carousel("prev"); });
$("#pause").click(function() { $(".carousel").carousel("pause"); });
$("#play").click(function() { $(".carousel").carousel("cycle"); });
$("#next").click(function() { $(".carousel").carousel("next"); });
$("#last").click(function() { $(".carousel").carousel(2); });
$(".carousel").on("slid.bs.carousel", function () {
affichage();
});
});
</script>
<!--Tooltip-->
<a data-toggle="tooltip" title="Tooltip">Tooltip</a>
<a data-toggle="tooltip" data-placement="bottom" title="Tooltip bottom">Tooltip bottom</a><!--also right and left-->
<script>
$(function() {
$("a").tooltip({trigger:"hover", delay:100}); // by default trigger:"hover", try click; delay in ms
});
</script>
<!--Popover-->
<a href="#" class="btn btn-info" data-toggle="popover" data-content="Popover" data-trigger="focus" title="Popover">Popover</a><!--data-trigger="focus" change the way popover goes away-->
<a href="#" class="btn btn-info" data-toggle="popover" data-content="<i>Popover</i>" data-html="true" title="<b>Popover</b>">Popover bottom</a><!--allow html in popover-->
<script>
$(function() {
$("a").popover(); //same as tooltip can be done here
});
</script>
<!--Panel-->
<div class="container">
<div class="col-lg-6">
<div class="btn-group btn-group-justified" data-toggle="buttons">
<label class="btn btn-primary active" id="show">
<input type="radio" name="options">Show
</label>
<label class="btn btn-primary" id="hide">
<input type="radio" name="options">Hide
</label>
<label class="btn btn-primary" id="toggle">
<input type="radio" name="options">Toggle
</label>
</div>
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title"> Je suis le titre de l'accordéon</h3>
</div>
<div class="panel-body"> Je suis le contenu de l'accordéon</div>
</div>
</div>
</div>
<script>
$(function() {
$(".panel").collapse();
$("#show, #hide, #toggle").click(function(){
$(".panel").collapse($(this).attr("id"));
});
});
</script>
<!--Scrollspy animation-->
<script>
$(function () {
$("li > a").on("click", function(e) {
e.preventDefault();
var hash = this.hash;
$("html, body").animate({
scrollTop: $(this.hash).offset().top
}, 1000, function(){
window.location.hash = hash;
});
});
});
</script>
</body>
</html>