html5颜色输入元素的事件处理程序 [英] Event handler for a html5 color input element

查看:101
本文介绍了html5颜色输入元素的事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Chrome中使用新的input =color元素会触发一个新的弹出对话框:



我想知道是否有一个事件处理程序在此预览中的值发生时触发(''colorinput')。on('change',function)在窗口中点击确定 (){//点击OK后触发
jQuery('#main').css('background-color',jQuery(this).val());
});

请参阅 http:/ /jsfiddle.net/Riesling/PEGS4/

解决方案

您正在寻找的是 输入事件



您的修改过的小提琴现在可以在所有(体面)浏览器中运行:


('input',function(){...})

  $('#colorinput' 


Using the new input="color" element within Chrome triggers a new popup dialog:

I would like to know if there is an event handler that fires as soon as the value in this preview window changes and not only after clicking on "OK"

jQuery('#colorinput').on('change', function() { // fires only after clicking OK
    jQuery('#main').css('background-color', jQuery(this).val()); 
 });​

See http://jsfiddle.net/Riesling/PEGS4/

解决方案

What you are looking for is the input event.

Your modified fiddle should now work in all (decent) browsers:

$('#colorinput').on('input', function() { ... } )

这篇关于html5颜色输入元素的事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆