Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jun 2013
    Location
    Macclesfield, England
    Posts
    5
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Unhappy Basic HTML/Java help?

    I have written this code in Notepad++ and the red div box shows, but the jQuery doesn't affect the div at all. Any help is appreciated, Thanks.

    HTML:

    <!DOCTYPE html>
    <html>
    <head>
    <script type='text/javascript' src='script1.js'>
    </script>
    <head>
    <body>
    <div style="background-color:red;height:50px;width:50px;">

    </div>
    </body>
    </html>

    JAVA:

    $(document).ready(function() {
    $('div').mouseenter(function() {
    $('div').fadeTo('fast',1);
    });
    $('div').mouseleave(function() {
    $('div').fadeTo('fast', 0.5);
    });
    });

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,982
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    See:- *** WARNING: Questions posted here will be deleted! ***.

    You will not get any reply in this forum which is intended to be used only to
    post a completed (working) script for showcasing/benefit of others.

    Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia!


    It is your responsibility to die() if necessary….. - PHP Manual

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    Jun 2013
    Location
    Macclesfield, England
    Posts
    5
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Sorry, my mistake, is there anyway I can delete this thread?

  • #4
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,955
    Thanks
    9
    Thanked 726 Times in 720 Posts
    If that's your entire code, then you haven't included jQuery itself - in my view this is best done by using the Google CDN.

    Just for info, jQuery is javascript, not java, which is a completely different language.
    Use the W3C HTML Validator and CSS Validator to check your code and Firebug to see what css is applied to an element
    Read Steve Krug's book Don't Make Me Think - essential reading on web usability
    I don't recommend much, but I do recommend Clook for UK web hosting

  • #5
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,662
    Thanks
    6
    Thanked 1,006 Times in 979 Posts
    Moved to JS frameworks forum.
    And please don’t cross-post.

  • #6
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,159
    Thanks
    23
    Thanked 599 Times in 598 Posts
    SB65 is correct. Please use [CODE] tags
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>  // ADDED
    <script type="text/javascript">
    $(document).ready(function(){
    	$('div').mouseenter(function() {
    	$('div').fadeTo('fast',0.4);                     // CHANGE TO 0.4
    	});
    
    	$('div').mouseleave(function() {
    	$('div').fadeTo('fast',1);                     // CHANGE TO 1
    	});
    });
    </script>
    </head>
    <body>
    <!DOCTYPE html>
    <html>
    <head>
    <script type='text/javascript' src='script1.js'>
    </script>
    </head>
    <body>
    <div style="background-color:red;height:50px;width:50px;"></div>
    </body>
    </html>
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Tags for this Thread

    Posting Permissions

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