javascriptjqueryfadeto

fadeTo() not working


I am having troubles using fadeTo() function in jQuery. It all worked for me at the begining but it stopped working now for some unknown reasons. Here i present you code of webpage. I will appreciate if you can help me.

<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="css/subscribe.css" />
<script type="text/javascript" src="js/jQuery.js"></script>
<script>
$(document).ready(function(){
subscribe = function(){
	$('#subscribe').fadeTo(500,1);
};
});
</script>
</head>

<body style="background:#fff;">
<a href="#" id="plus" onClick="subscribe();">+</a>
<div id="subscribe" style="opacity:0;"><?php include('subscribe.php'); ?></div>
<!--<video id="bgvid" width="100%" height="100%" style="position:absolute;opacity:1;" autoplay loop muted>
<source src="css/7dayz.mp4" type="video/mp4"></video>-->
<div id="wrapper_main" style="opacity:1;">
	<div id="center_main">
		<p><a href="#">LOOK</a></p>
		<p><a href="#">SHOP</a></p>
		<p><a href="#">JOURNAL</a></p>
	</div>	
</div>

</body>
</html>


Solution

  • Your code works : run it here. Click the + , it fades the word "SUBSCRIBE" in.

    subscribe = function(){
    	$('#subscribe').fadeTo(500,1);
    };
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <a href="#" id="plus" onClick="subscribe();">+</a>
    <div id="subscribe" style="opacity:0;">SUBSCRIBE</div>
    
    <div id="wrapper_main" style="opacity:1;">
    	<div id="center_main">
    		<p><a href="#">LOOK</a></p>
    		<p><a href="#">SHOP</a></p>
    		<p><a href="#">JOURNAL</a></p>
    	</div>	
    </div>

    Note : you can use .fadeIn() instead of .fadeTo(500,1)

    Try this :

    (HTML)

    <a href="#" id="plus">+</a>
    

    (JS)

    subscribe = function(){
            $('#subscribe').fadeIn();
        };
    
    $("a#plus").click(subscribe)