【问题标题】:JSColor not working with <i> element?JSColor 不适用于 <i> 元素?
【发布时间】:2017-05-17 21:44:39
【问题描述】:

我想使用 JScolor,但是当我按下一个元素时我似乎无法让它工作,这有点违背了它的目的。谁有解决办法?

<div class='drag resizable'>
    <ul class='list-inline'>
        <li>
            <textarea class='resizable' type='text'></textarea>
        </li>
        <li>
            <div class='buttonDiv'>
                <i class='fa fa-paint-brush fa-lg color' id='rect' aria-hidden='true'></i>
                <br>
                <i class='fa fa-trash fa-lg delete' aria-hidden='true'></i>
            </div>
        </li>
    </ul>
</div>

这是一个完整的 JSFiddle。

当您单击画笔时,它应该打开 JSColor 托盘,但它没有,对我来说它只适用于输入元素。

https://jsfiddle.net/0vjf9cdz/4/

【问题讨论】:

  • 你能贴一些代码吗?
  • “当你按下一个元素时让它工作”是什么意思?您可以在问题中使用示例代码吗?
  • 定义“似乎无法让它工作”。发生什么了?是否有任何错误信息?此外,如果不查看您的代码,我们不可能知道问题所在。
  • 添加了一个 JSFiddle

标签: javascript jscolor


【解决方案1】:

不能放过这个。烦死我了,哈哈。

https://www.w3schools.com/tags/tag_i.asp

元素根本不支持颜色属性...

【讨论】:

  • 不太清楚你对consolejs的意思?但是,是的,我的猜测是这根本不可能。
  • 正在我的手机上接听电话,并粘贴了以前的代码,然后在按 Enter 键时将其发布...累了抱歉。进行了编辑。
【解决方案2】:

这个例子很好用

            <ul>
              <li>
              <button
                class="pincel fa-paint-brush jscolor {valueElement:null,value:'66ccff', styleElement:'rect'}"
               >icon here</button>
              </li>
            </ul>
            <p id="rect" style="border:1px solid gray; width:161px; height:100px;">
            </p>
            <script>
            function update(jscolor) {
                // 'jscolor' instance can be used as a string
                document.getElementById('rect').style.backgroundColor = '#' + jscolor
            }
            </script>a

这里的例子https://jsfiddle.net/rollrodrig/judkgthd/1/

【讨论】:

  • 我知道,但这不是帖子的内容,我希望能够点击 元素,而不是输入。
猜你喜欢
  • 2020-04-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-03
  • 2021-07-31
  • 2018-03-26
  • 1970-01-01
相关资源
最近更新 更多