Skip to content

Instantly share code, notes, and snippets.

@koentjuh1
koentjuh1 / Replace image top background-image.js
Last active August 30, 2016 11:12
Replace image of <img> into css: background-image:url(''); to the parent.
$('.slider-block img').each(function() {
var imgSrc = $(this).attr('src');
$(this).parent().css({'background-image': 'url('+imgSrc+')'});
$(this).remove();
});
@koentjuh1
koentjuh1 / Random addClass acitve.html
Created August 30, 2016 09:31
Random addClass acitve
<div class="carousel-inner" role="listbox">
<div class="item" style="background-image: url(&quot;images/slider1.jpg&quot;);">
</div>
<div class="item" style="background-image: url(&quot;images/slider2.jpg&quot;);">
</div>
<div class="item" style="background-image: url(&quot;images/slider3.jpg&quot;);">
</div>
</div>
@koentjuh1
koentjuh1 / Add class to parent.html
Created August 30, 2016 10:09
Add class to parent and remove when clicked outside the element
<div class="click-box">
<div class="btn btn-default">click me</div>
<div class="click-content">
click content
</div>
</div>
@koentjuh1
koentjuh1 / Read more.html
Last active August 30, 2016 11:02
Read more jquery
$('article').readmore({
speed: 300,
collapsedHeight: 100,
lessLink: '<a href="#">Lees minder</a>',
moreLink: '<a href="#">Lees meer</a>'
});
@koentjuh1
koentjuh1 / Scroll to div.html
Created August 30, 2016 10:59
Scroll to div
/* Scroll button: */
<div class="arrow-icon scroll" data-rel="#arrow-scroll-to">
</div>
/* Scroll to: */
<div id="arrow-scroll-to">
</div>
@koentjuh1
koentjuh1 / Get height of div with jquery.js
Created August 30, 2016 11:09
Get height of div with jquery
$(document ).ready(function() {
var result = $(".row-about-us .left").height();
$(".row-about-us .right").css("height", result);
});
@koentjuh1
koentjuh1 / Set fixed header after scroll top.js
Last active August 30, 2016 11:20
Set fixed header after scroll top
// Version 1
function adjustHeader1(){
var head = jQuery('.header-bot');
if(jQuery(document).scrollTop() > 50) {
if(!head.hasClass('header-bot-fix')) {
head.addClass('header-bot-fix');
}
}
else {
if(head.hasClass('header-bot-fix')) {
@koentjuh1
koentjuh1 / Dropdown with search - chosen.md
Last active September 1, 2016 08:51
Dropdown with search - chosen
@koentjuh1
koentjuh1 / Sticky sidebar.html
Last active August 30, 2016 11:42
Sticky sidebar
<div class="container">
<div class="row">
<div class="col-sm-9 main-content">
<h1>Main content</h1>
</div>
<div class="col-sm-3 sidebar">
<div class="theiaStickySidebar">
<h3>Sidebar</h3>
</div>
</div>
/* Take ID of youtube video */
<div class="youtube" id="XqFl-S48NSw"></div>