вы увидите значения, и я хочу добавить запятую между ними, например, если это 2500, это должно быть 2500. Я много пробовал, но это просто - PullRequest
0 голосов
/ 04 мая 2020

код слайдера диапазона, мне нужно добавить запятую между словами! в диапазоне более старых значений это работает, но не может реализовать его для других значений! вы увидите значения, и я хочу добавить запятую между ними, например, если это 2500, то должно быть 2500. Я много пробовал, но это просто доцент. Если кто-нибудь из вас знает это, это было бы очень полезно

const allRanges = document.querySelectorAll(".ranges");
allRanges.forEach(wrap => {
  const range = document.getElementById("range");
  const bubble = document.getElementById("value");

  range.addEventListener("input", () => {
    setBubble(range, bubble);
  });
  setBubble(range, bubble);
});

function setBubble(range, bubble) {
  const val = range.value;
  const min = range.min ? range.min : 150000;
  const max = range.max ? range.max : 1000000;
  const newVal = Number(((val - min) * 100) / (max - min));
  bubble.innerHTML = val.replace(/\B(?=(\d{3})+(?!\d))/g, ",");

  var vvv = document.getElementById("vvv");
  var saved = document.getElementById("saved");
  var sameValue = document.getElementById("sameValue");
  var newspot = val / 100 * 3;
  var newTall = newspot - parseInt(2500);

  vvv.innerHTML = "$" + newTall;
  saved.innerHTML = "$" + newspot;
  sameValue.innerHTML = "$" + newspot;

  if (val > 995000) {
    document.getElementById("value").innerHTML = "$" + 1 + "M";
  }

  bubble.style.left = `calc(${newVal}% + (${8 - newVal * 0.15}px))`;
}
.pricing_sec {
  margin-top: 100px;
}

.pricing_bar {
  width: 50%;
  display: inline-block;
  margin: 0 auto;
}

.sec1 {
  width: 33%;
  float: left;
}

.sec1 h2 {
  font-weight: 400;
}

.sec1 h3 {
  font-weight: 600;
  font-size: 20px;
}

.sec2 {
  width: 33%;
  float: left;
}

.sec2 h2 {
  font-weight: 400;
}

.sec3 {
  width: 33%;
  float: left;
}

.sec3 h2 {
  font-weight: 400;
}

.sec3 h3 {
  font-weight: 600;
  font-size: 20px;
}

.pricing_sec {
  margin-top: 100px;
}

.pricing_bar {
  width: 50%;
  display: block;
  margin: 0 auto;
}

.sec1 {
  width: 33%;
  float: left;
}

.sec1 h2 {
  font-weight: 400;
}

.sec1 h3 {
  font-weight: 600;
  font-size: 20px;
}

.sec2 {
  width: 33%;
  float: left;
}

.sec2 h2 {
  font-weight: 400;
}

.sec3 {
  width: 33%;
  float: left;
}

.sec3 h2 {
  font-weight: 400;
}

.sec3 h3 {
  font-weight: 600;
  font-size: 20px;
}

.pricing_buttons {
  margin-top: 50px;
  width: 100%;
  display: inline-block;
}

.range-slider {
  display: flex;
  justify-content: center;
  position: relative;
}

.range-slider {
  width: 100%;
}

.range-slider__range {
  position: relative;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: linear-gradient(90deg, rgb(214, 214, 214) 60%, rgb(214, 214, 214) 60%);
  outline: none;
  -webkit-transition: 0.2s;
  opacity: 0.7;
  transition: all 0.2s ease-in-out;
  height: 20px;
  border-radius: 50px;
}

.range-slider__range:hover {
  opacity: 1;
}

.range-slider__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #1C85E8;
  cursor: pointer;
  -webkit-transition: background .15s ease-in-out;
  transition: all 0.2s ease-in-out;
  content: '';
  background: url('https://www.omahaflatfee.com/wp-content/uploads/2020/04/home-icon-white-silhouette-on-blue-round-vector-20326047.png');
  background-size: cover;
}

.range-slider__range::-moz-range-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #1C85E8;
  cursor: pointer;
  -webkit-transition: background .15s ease-in-out;
  transition: all 0.2s ease-in-out;
  content: '';
  background: url('https://www.omahaflatfee.com/wp-content/uploads/2020/04/home-icon-white-silhouette-on-blue-round-vector-20326047.png');
  background-size: cover;
}

.range-slider__range:focus::-webkit-slider-thumb {
  -webkit-box-shadow: 0 0 0 3px #ffffff, 0 0 0 6px #1C85E8;
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px #1C85E8;
}

.range-slider__value {
  padding: 4px 12px;
  position: absolute;
  border-radius: 4px;
  margin-left: 20px;
  transform: translateX(-50%);
  top: 40px
}

::-moz-range-track {
  background: #1C85E8;
  border: 0;
}

input::-moz-focus-inner,
input::-moz-focus-outer {
  border: 0;
}

.pricing_buttons .btn button {
  padding: 15px 80px;
  border: none;
  border-radius: 5px;
  background-color: #5CA4E8;
  color: white;
  font-size: 25px;
  font-weight: bold;
  box-shadow: 0px 5px 0px #1C85E8;
}

.pricing_buttons .btn button:hover {
  background-color: #1C85E8;
}

.chk {
  width: 80% !important;
  display: block;
  margin: 0 auto;
}

.chk p {
  margin-top: 40px;
  color: #6C6363;
  font-size: 18px;
  font-weight: 500;
  line-height: 25px;
}

@media(max-width:500px) {
  .chk p {
    margin-top: 30px;
    color: #6C6363;
    font-size: 15px;
    font-weight: 500;
    line-height: 25px;
  }
}

@media(max-width:503px) {
  .pricing_buttons .btn button {
    padding: 10px 50px;
    border: none;
    border-radius: 5px;
    background-color: #1C85E8;
    color: white;
    font-size: 15px;
    font-weight: bold;
    box-shadow: 0px 5px 0px #1C85E8;
  }
}

@media(max-width:351px) {
  .pricing_buttons .btn button {
    padding: 10px 30px;
    border: none;
    border-radius: 5px;
    background-color: #1C85E8;
    color: white;
    font-size: 10px;
    font-weight: bold;
    box-shadow: 0px 5px 0px #1C85E8;
  }
}

@media(max-width:767px) {
  .pricing_bar {
    width: 100%;
    display: inline-block;
    margin: 0 auto;
  }
  .sec1 {
    width: 100%;
    float: left;
  }
  .sec1 h2 {
    font-weight: 400;
  }
  .sec1 h3 {
    font-weight: 600;
    font-size: 20px;
  }
  .sec2 {
    width: 100%;
    float: left;
  }
  .sec2 h2 {
    font-weight: 400;
  }
  .sec3 {
    width: 100%;
    float: left;
  }
  .sec3 h2 {
    font-weight: 400;
  }
  .sec3 h3 {
    font-weight: 600;
    font-size: 20px;
  }
}
<div class="ranges">
  <div class="container">
    <div class="row">
      <div class="col-12 col-l-12">
        <div class="range-slider">
          <input id="range" class="range-slider__range" type="range" value="150000" step="5000" min="150000" max="1000000">

          <span id="value" class="range-slider__value">0</span>

        </div>
      </div>
    </div>
  </div>
</div>

<div class="words text-center mt-5">
  <div class="container">
    <div class="row pricing_sec">
      <div class="col-12 col-lg-12 pricing_bar">
        <div class="col-lg-5 sec1">
          <div class="values">
            <h2>$2,500</h2>
            <h3>OMAHA FLAT FEE</h3>
          </div>
        </div>
        <div class="col-lg-2 mb-sm-2 mb-md-2 mb-lg-0 mt-3 mt-sm-0 mt-md-3 sec2">
          <div class="values">
            <h2>VS</h2>
          </div>
        </div>

        <div class="col-lg-5 sec3">
          <div class="values">
            <h2 id="saved">$4500K</h2>
            <h3>Traditional agent commission*</h3>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<div class="pricing_buttons text-center">
  <div class="container">
    <div class="row">
      <div class="col-12 col-lg-12">
        <div class="btn">
          <button>Click to Save <span id="vvv">$2000K</span></button>
        </div>
        <div class="chk text-sm-center text-md-center">
          <p>Savings calculations based on difference between 3% listing agent commission and Homie’s flat listing fee. Savings may vary.</p>
        </div>

      </div>
    </div>
  </div>
</div>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...