Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

fadein fadeout jquery

	$('.btn-cart').click(function(e) {
		e.preventDefault();
		$('.cartlist').fadeIn().addClass('active');
	});

	$('.btn-cartlist-close').click(function() {
		$('.cartlist').removeClass('active').fadeOut();
	});
Comment

jquery fadeout and remove

<a onclick='$("#notification").fadeOut(300, function() { $(this).remove(); });' class="notificationClose "><img src="close.png"/></a>
Comment

jquery fade out

$(selector).fadeOut(duration)
$(selector).fadeIn(duration)
Comment

javascript fadeout without jquery

if (!Element.prototype.fadeIn) {
    Element.prototype.fadeIn = function(){
        let ms = !isNaN(arguments[0]) ? arguments[0] : 400,
            func = typeof arguments[0] === 'function' ? arguments[0] : (
                typeof arguments[1] === 'function' ? arguments[1] : null
            );

        this.style.opacity = 0;
        this.style.filter = "alpha(opacity=0)";
        this.style.display = "inline-block";
        this.style.visibility = "visible";

        let $this = this,
            opacity = 0,
            timer = setInterval(function() {
            opacity += 50 / ms;
            if( opacity >= 1 ) {
                clearInterval(timer);
                opacity = 1;

                if (func) func('done!');
            }
            $this.style.opacity = opacity;
            $this.style.filter = "alpha(opacity=" + opacity * 100 + ")";
        }, 50 );
    }
}

if (!Element.prototype.fadeOut) {
    Element.prototype.fadeOut = function(){
        let ms = !isNaN(arguments[0]) ? arguments[0] : 400,
            func = typeof arguments[0] === 'function' ? arguments[0] : (
                typeof arguments[1] === 'function' ? arguments[1] : null
            );

        let $this = this,
            opacity = 1,
            timer = setInterval( function() {
            opacity -= 50 / ms;
            if( opacity <= 0 ) {
                clearInterval(timer);
                opacity = 0;
                $this.style.display = "none";
                $this.style.visibility = "hidden";

                if (func) func('done!');
            }
            $this.style.opacity = opacity;
            $this.style.filter = "alpha(opacity=" + opacity * 100 + ")";
        }, 50 );
    }
}

// fadeIn with default: 400ms
document.getElementById(evt.target.id).fadeIn();

// Calls the "alert" function with the message "done!" after 400ms - alert('done!');
document.getElementById(evt.target.id).fadeIn(alert);

// Calls the "alert" function with the message "done!" after 1500ms - alert('done!');
document.getElementById(evt.target.id).fadeIn(1500, alert);
Comment

javascript fadeout without jquery

if (!Element.prototype.fadeIn) {
    Element.prototype.fadeIn = function(){
        let ms = !isNaN(arguments[0]) ? arguments[0] : 400,
            func = typeof arguments[0] === 'function' ? arguments[0] : (
                typeof arguments[1] === 'function' ? arguments[1] : null
            );

        this.style.opacity = 0;
        this.style.filter = "alpha(opacity=0)";
        this.style.display = "inline-block";
        this.style.visibility = "visible";

        let $this = this,
            opacity = 0,
            timer = setInterval(function() {
            opacity += 50 / ms;
            if( opacity >= 1 ) {
                clearInterval(timer);
                opacity = 1;

                if (func) func('done!');
            }
            $this.style.opacity = opacity;
            $this.style.filter = "alpha(opacity=" + opacity * 100 + ")";
        }, 50 );
    }
}

if (!Element.prototype.fadeOut) {
    Element.prototype.fadeOut = function(){
        let ms = !isNaN(arguments[0]) ? arguments[0] : 400,
            func = typeof arguments[0] === 'function' ? arguments[0] : (
                typeof arguments[1] === 'function' ? arguments[1] : null
            );

        let $this = this,
            opacity = 1,
            timer = setInterval( function() {
            opacity -= 50 / ms;
            if( opacity <= 0 ) {
                clearInterval(timer);
                opacity = 0;
                $this.style.display = "none";
                $this.style.visibility = "hidden";

                if (func) func('done!');
            }
            $this.style.opacity = opacity;
            $this.style.filter = "alpha(opacity=" + opacity * 100 + ")";
        }, 50 );
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: react js get screen size 
Javascript :: use eslint in vscode 
Javascript :: number object js 
Javascript :: add new element useState array 
Javascript :: what is cdn react 
Javascript :: sleeping in js 
Javascript :: nodejs how to send html 
Javascript :: Razorpay generate Signature in the node js 
Javascript :: extract payload of expired jwt token in js 
Javascript :: gsap pin scrolltrigger 
Javascript :: detect if two line segments intersect each other javascript 
Javascript :: store data to the browser’s localStorage 
Javascript :: slide out navigation 
Javascript :: every method javascript 
Javascript :: javascript log html element as dom object 
Javascript :: download jquery 
Javascript :: js convert date to timestamp 
Javascript :: check if two rectangles overlap javascript canvas 
Javascript :: to lowercase js 
Javascript :: @react-google-maps/api npm 
Javascript :: chrome extension open new tab from popup 
Javascript :: e.target.text react 
Javascript :: handlerbar console log 
Javascript :: js data object length 
Javascript :: js array clone 
Javascript :: javascript object chain 
Javascript :: typescript class constructor overload 
Javascript :: pipe data to json angular 
Javascript :: "SyntaxError: Unexpected token o in JSON at position 1 
Javascript :: how to set input date to today date on initialization 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =