【问题标题】:Range slider change giving [object Object] error范围滑块更改给出 [object Object] 错误
【发布时间】:2016-05-12 15:50:48
【问题描述】:

希望范围滑块的值显示在滑块旁边。在 roadtripsharing.com/map-it 页面上,它给出了 [object Object] 错误,但是当我将 html 和脚本剪切并粘贴到 sn-p(如下)中时,它似乎根本不起作用,并抛出“意外输入错误结束。

我做错了什么,我该如何解决?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="range" min="0" max="100" value="33" id="rtsfader" style="display:inline-block">&nbsp;<output for="rtsfader" id="rtsmileage">33</output>&nbsp; miles
<script type="text/javascript">
function rtsoutputUpdate(vol) {
	document.querySelector('#rtsmileage').value = vol;
  console.log(vol); 
}
</script>

【问题讨论】:

  • rtsoutputUpdate() 函数是如何被调用的?
  • 不确定,我想也许它只是自动发生的。 html5 的好东西!

标签: javascript jquery html object rangeslider


【解决方案1】:

其实,你不需要 jQuery / JS。只需用 &lt;form&gt; 元素包围 &lt;input&gt; 和 &lt;output&gt;。

<form oninput="rtsmileage.value = rtsfader.value">
      <input type="range" min="0" max="100" value="33" id="rtsfader" style="display:inline-block">&nbsp;<output for="rtsfader" id="rtsmileage">33</output>&nbsp; miles
<form>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-24
    • 1970-01-01
    • 2016-03-26
    • 1970-01-01
    • 1970-01-01
    • 2020-06-14
    • 2020-04-12
    相关资源
    最近更新 更多