Close div when clicked

  • Started
  • Last post
  • 25 Responses
  • ********
    0

    I personally think you should maybe take a step back with the complexity of what you're attempting, as you aren't writing valid code at the moment.

    I don't mean this to offend you, as I'm also relatively new to jQuery and Javascript. You're probably finding that jQuery isn't doing what you want it to and it's not necessarily because your thinking is failing you, but you're just not writing your code validly.

    $(document).ready(function () {
    .load(function () {
    // set the image hidden by default
    $('#fader').hide();.fadeIn(300);
    }}

    This block will not work as you aren't closing your functions. You have 8 '(' brackets and only 6 ')' brackets.

    If you're loading multiple 'fader' objects, you should be using classes rather than ID's ( '.' rather than '#' ), and also to make it easier and to make the fader objects not rely on jQuery for their default state, give their css property a display:none rather than hiding them when jQuery loads.

    The best way to learn jQuery, or any language, quickly is to break down what your targets are into smaller sections and learn it incrementally, rather than going from nothing to what sounds like an animated AJAX website.

    Get your fader stuff working properly before you bring AJAX into the equation.

    I think asides from the fact your code won't be running, your problem is you are using the same ID for multiple objects. Try giving the HTML objects a class of 'fader' rather than an ID.

    • check this
      $('#fader').hide...
      wrong syntax
      ********
  • ernexbcn0

    You want the image with id #fader to hide on click?

    $('#fader').live('click', function() {
    //do something here with the element, for instance:
    $(this).fadeOut(300);
    });

    • No man, want img with class 'fader' to fade in on load. 500Kb+ images.Q01
  • Q010

    Cheer Orrin —

    I've tried to build that way. I came up with an initial concept with the slide in viewer. Got that working. Got the content loading in. Now I'm working on smoothing it all out. I have tried to build the site incrementally — thinking doing this would help me better understand JQuery along the way. (Obviously not)

    Thanks for the words.

    • Cheers*Q01
    • Don't be discouraged by it, but you'll find it much easier working in smaller steps.
      ********
  • ********
    0

    put inline css display:none on image then call jQuery on page load $("#yourimageid").fadeIn()

  • ********
    0

    Look into jQuery lazyload