The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Hide div "foo" if top-div´s class is "bar"

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #200650

    So I am designing a site for my own thing on BigCommerce. I decided to go with separate designs for separate purposes using only product-categories. This is fully okay, except for one little detail. The product categories have lots of functionality, but their whole system (BC) is built on PHP-includes. One file needs the other and nothing is accessible unless you are in the right file for the HTML-thing you´re trying to construct. And I´m trying to use different categories for different purposes with separate designs and structures. Therein lies the problem, that´s at the moment easier said than done, since you cannot access any PHP-code in themes, only HTML-snippets and JavaScript.

    Anyway, here is my actual question:

    Can I write a script to find the class of a parent div, and then hide some content based on the read result?

    Like so:
    (horrible imitation of jscript)

    if div with name “foo” is present: hide/remove element with class “bar”

    elseif div with name “foo-2” is present: hide/remove element with class “bar-2”

    I know this is a crappy alternative, as many computers on many public places have javascript disabled, or use IE and other strange things :/, but combined with triggered CSS-trickery I can account for both “noscript” and script-enabled browsers. However, I would like for the browser to not include the unnecessary HTML if possible. If there is server-side JavaScript, that would be best, but not sure that´s possible to run in this environment, or even at all without proper libraries on the BigCommerce servers.

    I guess there´s a post about this issue somewhere, please point me in the right direction if no direct answers are available.

    Thanks upfront.

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.