Показать сообщение отдельно
  #8 (permalink)  
Старый 20.01.2016, 17:36
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,070

ureech,
<!doctype html>
<html>
  <head>
    <meta charset="utf-8" />
    <title></title>
    <style type="text/css">
    .component {
      background-color: Chocolate;width:100%; height: 100px; margin-top: 10px;
    }

    </style>
  </head>
  <body>
    <div class="tabs-wrap">
      <button class="tab" data-color="gray">Gray</button>
      <button class="tab" data-color="red">Red</button>
      <button class="tab" data-color="blue">Blue</button>
    </div>

    <div class="component" ></div>

    <script src="https://code.jquery.com/jquery-2.1.4.js"></script>

    <script>
$(function() {
    var a = $(".component").css("backgroundColor");
    $(".tabs-wrap").on("click", ".tab", function() {
        var b = $(".component").css("backgroundColor"),
            c = $(this).data("color");
        $(".component").css({
            backgroundColor: c
        });
        $(".component").css("backgroundColor") == b && $(".component").css({
            backgroundColor: a
        })
    })
});
    </script>
  </body>
</html>
Ответить с цитированием