Показать сообщение отдельно
  #5 (permalink)  
Старый 18.02.2017, 21:59
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,075

jQuery UI range slider to show and hide blocks of content
Galyanov,
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery UI range slider to show and hide blocks of content</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/south-street/jquery-ui.css">
<style>
h1{margin:0.5em}
.ui-slider{width:650px;margin:2em 1em}
#blocks-container{float:left;margin:0 1em}
#blocks-container div{float:left;width:120px;height:100px;margin:0.5em;padding:1em;border:1px solid gray;background:#C0C0C0}
#slider{margin:10px;width:500px;height:8px}
.ui-slider-handle{border-radius:50%;position:relative;font-size:14px;display:block}
.ui-slider-horizontal .ui-slider-handle{top:-0.4em;background:#00F}
:focus{outline:0;border:0}

#blocks-container > div{
     display: none;
}
#blocks-container > div:nth-child(1){
  display:  block;
}
</style>

  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

</head>
<body>

<h1>тариф 1</h1>

<div id="slider"></div>

<div id="blocks-container">
  <div>Content 1</div>
  <div>Content 2</div>
  <div>Content 3</div>
  <div>Content 4</div>
</div>
<script>
$(function() {
  var blocks = $("#blocks-container").children(), h = $("h1");
 // blocks.hide().eq(0).show()  в css
  function showHide(event, ui) {
   var range = +ui.value;
   blocks.hide().eq(range).show();
   h.html("тариф "+ (range+1))
  }
  $("#slider").slider(
    {
    animate: true,
    range: "min",
    value: 0,
    min: 0,
    max: 3,
    step: 1,
    slide: showHide
    }
  );
 });
</script>
</body>
</html>

Последний раз редактировалось рони, 18.02.2017 в 22:01.
Ответить с цитированием