Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jquery fadein

$(".example").fadeIn(500);
Comment

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 fade out

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

jquery fadeout to fadein

$('#ToHide').fadeOut(function () { $('#ToShow').fadeIn(); });
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 hooks componentdidmount 
Javascript :: react build command 
Javascript :: even or odd in javascript 
Javascript :: largest and smallest number in an array 1-100 javascript 
Javascript :: input two decimal places javascript 
Javascript :: spining load react component 
Javascript :: how to give width through props 
Javascript :: get minutes and seconds of long seconds 
Javascript :: useref react 
Javascript :: adding all elements of an array javascript 
Javascript :: set file upllaod via javascript to html input 
Javascript :: how to display image before upload in jhtml 
Javascript :: how to know if select input has been selected in js 
Javascript :: install specific version of npm for your project 
Javascript :: leaflet change marker location 
Javascript :: phone number with dashes 
Javascript :: mongoose save or update 
Javascript :: generators in javascript 
Javascript :: resize array javascript 
Javascript :: vue custom events 
Javascript :: angular return observable with error 
Javascript :: typescript/JavaScript time ago from datetime 
Javascript :: set lodash 
Javascript :: set interval 
Javascript :: eventemitter in angular 
Javascript :: use these instead of a for loop javascript 
Javascript :: discord.js timeout 
Javascript :: react google maps 
Javascript :: capitalize first letter 
Javascript :: parse integer in javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =