Jak mogę ukryć element div i wyświetlać go tylko wtedy, gdy na stronie istnieje inny element div? Zgaduję jQuery lub js byłoby do zrobienia ....Wyświetl element tylko wtedy, gdy istnieje inny element.
<style type="text/css">
.always-here {
display:none;
}
</style>
<div class="im-here">This div exists on this particular page!</div>
<div class="always-here">This div is always here but has the style
display: none unless a div with the class "im-here" exists.</div>
Wow, nie miał pojęcia, że można to rozwiązać za pomocą CSS. Czy ta metoda jest zgodna z przeglądarką? – Heather
@Heater patrz http://reference.sitepoint.com/css/generalsiblingselector, https://developer.mozilla.org/en-US/docs/Web/CSS/General_sibling_selectors, https://www.google.tt/ search? q = general + sibling + selector i oq = general + sibling + selector & aqs = chrome..69i57j0l3.6681j0 & sourceid = chrome & ie = UTF-8 # fp = 828651ec3b51e1b8 & q = css + ogólne + sibling + selektor + przeglądarka + wsparcie – Musa