Páricsi Zoltán Páricsi Zoltán - 1 year ago 68
CSS Question

How to set css for first div, if there's no second div

I want to set

<div class="first">
, only if there's no
<div class="second">

Do you have any idea how to do it?

Answer Source

It is not possible using CSS only. Here is an example to do it with jQuery:

if ($('.second').length == 0) {
    $('.first').css('border-radius', '0 0 2px 2px');

With $('.second').length == 0 you check, wether an element of class second exists or not. You can read more about jQuery's css() function on the documention.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download