Results 1 to 3 of 3

Thread: fadeIn & fadeOut div content onClick image button

  1. #1
    Join Date
    Jul 2009
    Location
    Binus University
    Posts
    472
    Thanks
    78
    Thanked 21 Times in 21 Posts

    Default fadeIn & fadeOut div content onClick image button

    i want to show div content onClick, image button. How to make this?
    I find this demo, but the demo already show the content first. and they use button and value instead of image. How to edit this.

    Thank you so much...
    Last edited by davelf; 05-20-2012 at 04:58 AM.
    _____________________

    David Demetrius // davejob
    _____________________

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    image buttons should only be used to submit a form but

    Code:
    <HTML>
    <HEAD>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <TITLE>FadeIn FadeOut Div using jQuery - DEMO</TITLE>
    <STYLE>
    body, input{
    	font-family: Calibri, Arial;
    }
    
    #sometext {
    	width: 150px;
    	height: 150px;
    	padding: 10px;
    	border:1px solid black;
    	background-color: #FFEE88;
    }
    </STYLE>
    </HEAD>
    <BODY>
    <H2>FadeIn FadeOut Div using jQuery - Demo</H2>
    <p>Click here to view the Tutorial: <a href="http://viralpatel.net/blogs/2009/01/fadein-fadeout-fade-out-effect-in-html-text-div-using-jquery.html">FadeIn FadeOut Div using jQuery</a></p>
    
    <input type="image" src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" value="FadeIn" onclick="fade('sometext', this)"/>
    <br/><br/>
    <div id="sometext">
        This text will Fade In and Out.
    </div>
    
    
    </BODY>
    <SCRIPT>
    function fade(div_id, button) {
    
    	if(button.value == 'FadeOut') {
    		$('#'+div_id).fadeOut('slow');
    		button.value = 'FadeIn';
    	}
    	else {
    		$('#'+div_id).fadeIn('slow');
    		button.value = 'FadeOut';
    	}
    }
    
    $('#sometext').fadeOut(2);
    
    </SCRIPT>
    </HTML>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. The Following User Says Thank You to vwphillips For This Useful Post:

    davelf (05-20-2012)

  4. #3
    Join Date
    Jul 2009
    Location
    Binus University
    Posts
    472
    Thanks
    78
    Thanked 21 Times in 21 Posts

    Default

    Thank you so much Vic.

    I have another problem, here. How to change the image?
    so for example i have this button "show" and after the div content appear, the button change to "hide"
    Last edited by davelf; 05-20-2012 at 05:01 AM.
    _____________________

    David Demetrius // davejob
    _____________________

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •