jquery - 如何在类型为 ="range"的 CANVAS 中更改颜色?

标签 jquery html css canvas

我想使用 type="range" 输入更改蓝色,我已经做到了这一点 jsFiddle .但需要进一步的帮助,因为我不具备成功完成任务的知识。使用 jquery 或 javascript 可能/更容易吗?我通常更喜欢 jquery。

<svg id="ett">
<defs>
    <filter id="f1" x="0" y="0">
      <feGaussianBlur in="SourceGraphic" stdDeviation="15" />
    </filter>
  </defs>
  <rect class="tva" filter="url(#f1)" />
</svg>
<form>
<input type="range" id="testr">
</form>


#ett{border-style:solid;
height:250px;
width:250px;}
.tva{height:250px;
width:250px;
stroke:red;
stroke-width:50px;
fill:blue;}

最佳答案

将 YOUR_CALCULATED_VALUE 下面的代码更改为计算值。它应该有效。

$("input[type=range]").change(function(){
    console.log($(this).val()); // output in console current position
    $(".tva").css("fill", YOUR_CALCULATED_VALUE)
})

关于jquery - 如何在类型为 ="range"的 CANVAS 中更改颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42944922/

相关文章:

javascript - Camanjs 过滤器完成回调(camanjs 中的事件)

javascript - 将元素随机放置在一个圆圈中

javascript - 单击按钮时触发事件

android - 如何在保护 child 的同时让 parent 居中

html - @media only screen and (max-device-width : 480px) didn't work

jquery - 使用 Twitter Bootstrap 时 Rails 中 Masonry 的问题。

javascript - 如何在 document.writes 中注入(inject) CSS?

jquery - 如何使用 Flask 从 devbridge 实现 jquery 自动完成?

Jquery 模板和小于号 (<) 或大于号 (>)

jquery - 使用 jquery 通过 3 级下拉导航进行键盘选项卡导航