1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to hide a Div Content !

Discussion in 'HTML & Website Design' started by themes4all, Apr 16, 2013.

  1. #1
    hello all,

    i need a Div to appear in just the Homepage and Disappear on all other Pages!

    I tried with jquery Remove and Hide div ID but it's don't work! any other idea !

    Thank you in advance!

    --------------------

    It's have been Resolved !
     
    Last edited: Apr 16, 2013
    themes4all, Apr 16, 2013 IP
  2. wiicker95

    wiicker95 Well-Known Member

    Messages:
    438
    Likes Received:
    37
    Best Answers:
    10
    Trophy Points:
    100
    #2
    FYI, that's not jQuery's job. You can eventually do it with php or with js (not recommended), but there's no need to include a 100k library for this. Not that the library in question serves to any good purpose in the first place.
     
    wiicker95, Apr 16, 2013 IP
  3. themes4all

    themes4all Well-Known Member

    Messages:
    662
    Likes Received:
    47
    Best Answers:
    6
    Trophy Points:
    100
    #3
    i already resolved this with Jquery Code and css :) So nothing Big :)
     
    themes4all, Apr 16, 2013 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #4
    Apart from wasting even more bandwidth by crapping all over your site with jquery and sending something in the markup that probably shouldn't even be there to do something that should be handled SERVER-side!
     
    deathshadow, Apr 16, 2013 IP
  5. danramosd

    danramosd Active Member

    Messages:
    115
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    83
    #5
    My preferred way of doing this is to render an ID on the body when the page loads with the name of the page. This can be done on the server side, here's an example in PHP.
    <html>
    <head></head>
    <body id='<?php echo substr($_SERVER[REQUEST_URI], 1, -4);'?>>
    </body>
    </html>
    PHP:
    Now you can have styles specific to each page by prefixing your CSS rules with #pageName. Without seeing your actual code, this example might be a little more helpful

    <html>
    <head></head>
    <body>
    <?php if( substr( $_SERVER[REQUEST_URI], 1, -4) == 'home'): ?>
    <div>This div will only show on the home page</div>
    <?php endif; ?>
    </body>
    </html>
    PHP:
    One last thing to note is that the method I'm using assumes all PHP files are located in the top level directory and all contain the .php extension. You might have to adjust the code if your URL routing and linking is setup differently.
     
    danramosd, Apr 16, 2013 IP
  6. udores

    udores Member

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #6
    I agree this is good with php. But i prefer jQuery instead, it just leaves your html simple and clean:):

    
    <body>
       <div id="targetDiv"></div>
    </body>
    
    <script>
    $(document).ready(function(){
       $('#targetDiv').hide();
    });
    </script>
    
    Code (markup):
    Attach the script to only pages you want the target div to be hidden.
     
    udores, Apr 17, 2013 IP
  7. wiicker95

    wiicker95 Well-Known Member

    Messages:
    438
    Likes Received:
    37
    Best Answers:
    10
    Trophy Points:
    100
    #7
    And adds pointless 78kb to your page. When it comes to html, server scripting is not even visible client-side. Your argument makes no sense.
     
    wiicker95, Apr 17, 2013 IP
  8. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #8
    Exactly, why the devil waste bandwidth sending client side garbage in the markup you aren't even going to show? Much less throwing even MORE code at it for no good reason in the form of javascript.

    Particularly when said scripting isn't even going to work for search engines, screen readers, or non CSS users? MUCH LESS the idiotic TRAIN WRECK OF STUPIDITY known as jQuery!!!

    All to do a simple IF statement and/or maybe an include server side? That's dumb as fried ****!

    Though admittedly I say that 99.99% of the time the garbage bloated dumbass nonsense I cannot fathom why ANYONE wants to piss all over their own websites with known as jQuery is involved.

    Pretty much if someone says "use jQuery" -- DON'T! It's either garbage that doesn't belong client side, something that could be written smaller and simpler without it, or something that has no malfing business on a website in the first place!
     
    deathshadow, Apr 17, 2013 IP
  9. udores

    udores Member

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #9
    please, kindly give me the link to a site you've designed that'll load in on my computer at <100k. I'll be glad to know if its functional or even gets visited at all.
    Let's leave all this crap argument about jquery and javascript and face the true point: <b>EVERY PROGRAMMER WITH HIS OWN STYLE</b>.
    No matter the work you've done on a page with php, user experience requirements may still require that some client side scripting be done on the page to improve your site's accessibility and usability. <b>They don't cancel each other out, they complement each other</b>
     
    udores, Apr 20, 2013 IP
  10. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #10
    http://www.ewiusb.com/

    ... and the contact form runs ~20 messages a day (which is pretty healthy for a static site that's not seen an update since Nov 2012). Home page: 98k in 22 files... featuring things I'm sure from your posts you thumb your nose at despite being essential for the page to be useful to as many users as possible like semantic markup, graceful degradation, elastic semi-fluid responsive layout, dynamic fonts, color contrasts that meet accessibility norms, etc, etc... As a rule of thumb my ideal target size for a content-less template is 72k in 12 files-- that's HTML+CSS+SCRIPTS+IMAGES -- and for a normal content page the upper limit I'd allow is 144k in 24 files... there are exceptions like image galleries (of course), but for most websites and most pages, there's NO reason to break past those numbers apart from the ineptitude, ignorance, or just plain apathy of the developer.

    Show me a page that uses jQuery that isn't an inaccessible broken slow annoying fat bloated mess! I've never seen one!!! Of course every time I say that, the person so challenged usually wusses out! Ok hotshot, let's see one of yours!

    ... and a lot of those "styles" are garbage inaccessible bloated slow trash from a mix of idiotic choices in off the shelf frameworks; be it javascript or HTML/CSS. When you have people out there starting out with 100k OR MORE code between the HTML+CSS+SCRIPTS before they even have semantic markup of their content (or a reasonable facsimily) there's something WRONG with said folks methodologies. When you have people sleazing out 100k of HTML 3.2 with 4 tranny or 5 lip-service around it, mated to hundreds of K of CSS with hundreds of K of Javascript for nothing thanks to fat bloated frameworks, it's time to start calling a turd a turd, and stop trying to dump a can of shellac on it.

    By definition scripting NEVER enhances accessibility since whatever you've done doesn't work scripting off, blocked, or otherwise unavailable; and with more and more people downloading extensions for FF or Chrome like NOSCRIPT (or in my case using Opera's in-built per-site blocking)... though you are semi-right with this:

    By semi right good scripting on a content driven website should ENHANCE functionality, but never replace it. For most websites if you can't make it functional without scripting, you might want to do the world a favor, back the **** away from the keyboard and take up something a bit less detail oriented like macramé.

    Semantic markup of content, bent to your will for all the different layoutS (YES, PLURAL!) with CSS, enhanced as needed/desired with scripting, IN THAT ORDER. Anything else is 99% of the time an accessibility train wreck of half-assed sleazy practices. Anyone telling you otherwise is packing you so full of sand you could change your name to Sahara.
     
    deathshadow, Apr 21, 2013 IP
  11. themes4all

    themes4all Well-Known Member

    Messages:
    662
    Likes Received:
    47
    Best Answers:
    6
    Trophy Points:
    100
    #11
    can't understand how a Resolved Problem can Get a lot of answers like that LOL So funny but Instructive :) Thank you all for the Answers even though there is Some Who Just Drop Down them Anger against Jquery :)
     
    themes4all, Apr 22, 2013 IP