Skip to content

Instantly share code, notes, and snippets.

View sealucky7's full-sized avatar

sea-lucky sealucky7

  • My Life :)
View GitHub Profile
<div class="top-line-wrapper" id="top-line">
<div class="top-line-anchor"></div>
<div id="top-line-fixed" class="top-line">
your content
</div>
</div>
var StickyElement = function(node){
var doc = $(document),
:invalid {
box-shadow: none;
}
:-moz-submit-invalid {
box-shadow: none;
}
:-moz-ui-invalid {
box-shadow:none;
your div{
display: none;
position: fixed;
}
jQuery(function(f){
var element = f('your div');
f(window).scroll(function(){
element['fade'+ (f(this).scrollTop() > 600 ? 'In': 'Out')](300);
});
@sealucky7
sealucky7 / cutLongText
Created March 17, 2017 08:54
cutLongText
function cutLongText() {
var elem, size, text;
size = 120;
elem = $('your classes or id');
$.each(elem,function(){
text = $(this).html();
if (text.length > size) {text = text.slice(0, size);}
$(this).html(text + '...');
});
console.log(elem);
<span class="form-group">
<span id="decrease">-</span>
<input id="htop" type="text" value="1">
<span id="increase">+</span>
</span>
var elm = $('#htop');
function spin( vl ) {
elm.val( parseInt( elm.val(), 10 ) + vl );
}
$(document).ready(function() {
$('.answer').hide();
$('.main h2').on('click', function () {
var $answer = $(this).next('.answer');
if ($answer.is(':hidden')) {
$answer.slideDown();
$(this).addClass('close');
} else {
$answer.slideUp();
$(this).removeClass('close');
var win = $(window);
function windowSize(){
if ($(window).width() <= '600' && win.scrollTop() > 600){
$('.order-mobile').fadeIn('slow');
} else {
$('.order-mobile').fadeOut('slow');
}
}
$(window).load(windowSize()); // при загрузке
var topLine = $('.top-line');
$(window).scroll(function (){
var top = $(this).scrollTop();
if (top > 120) {
topLine.addClass('fixed');
} else {
topLine.removeClass('fixed');
}
input {
-webkit-appearance: none;
-webkit-border-radius: 0;
}
$(" your element").click(function()
{
$(this).next("your element").slideToggle('normal');
});