Skip to content

Instantly share code, notes, and snippets.

@levnhub
Last active April 26, 2018 15:56
Show Gist options
  • Select an option

  • Save levnhub/96ce520200dac5127906d872aba05a80 to your computer and use it in GitHub Desktop.

Select an option

Save levnhub/96ce520200dac5127906d872aba05a80 to your computer and use it in GitHub Desktop.
Pure JS Snippets
// Media Queries
function myFunction(x) {
if (x.matches) { // If media query matches
document.body.style.backgroundColor = "yellow";
} else {
document.body.style.backgroundColor = "pink";
}
}
var x = window.matchMedia("(max-width: 700px)")
myFunction(x) // Call listener function at run time
x.addListener(myFunction) // Attach listener function on state changes
// Selectize disable input
$('.selectize-single-select.without-input').next().find('div.selectize-input > input').prop('disabled', 'disabled');
// Fix selects jumping
$('.selectize-dropdown.without-input').each(function () {
// Get dropdown width
var width = parseInt($(this).css('width'));
// Set input width
$(this).siblings('.selectize-input').css('min-width', width + 7 + 'px');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment