Skip to content

Instantly share code, notes, and snippets.

View Bewitchedyegor's full-sized avatar

Yegor Ostapenko Bewitchedyegor

View GitHub Profile
@Bewitchedyegor
Bewitchedyegor / optionSelected.js
Created October 31, 2017 08:57
Add action on option being selected in dropdown
$('#list').change(function() {
if ($(this).val() === '2') {
// Do something for option "b"
}
});
@Bewitchedyegor
Bewitchedyegor / placeholderTrick.html
Created November 6, 2017 09:29
Hide placeholder on input click, get it back on blur when nothing is entered
<input
type="text"
placeholder="enter your text"
onfocus="this.placeholder = ''"
onblur="this.placeholder = 'enter your text'" />
@Bewitchedyegor
Bewitchedyegor / stylingScroll.css
Created November 6, 2017 11:45
Styling scrollbar appearance
.selector::-webkit-scrollbar {
width: 5px;
}
.selector::-webkit-scrollbar-track {
-webkit-box-shadow: transparent;
}
.selector::-webkit-scrollbar-thumb {
border-radius: 10px;
background: #40c4e8;
-webkit-box-shadow: none;
@Bewitchedyegor
Bewitchedyegor / charCount.js
Created November 9, 2017 10:08
Character count
$('textarea').on('input', function () {
$(".js-countChar").fadeIn();
});
$('textarea').on('input', updateCount);
function updateCount() {
var cs = [150 - $(this).val().length];
$('#characters').text(cs);
}
@Bewitchedyegor
Bewitchedyegor / add_hashtag.vue
Created January 4, 2018 12:09
Add hash to current link inside browser address bar without reloading the page
<template>
<a href="#cfd" @click="updateLink()">
</template>
<script>
export default {
methods: {
updateLink: function() {
var href = event.currentTarget.getAttribute('href');
history.pushState("", "", "cfd_products"+href);
}