草庐IT

re-input

全部标签

javascript - 哪些浏览器支持在 input[type ="file"] 元素上触发点击事件?

根据https://developer.mozilla.org/en/Using_files_from_web_applications,StartinginGecko2.0(Firefox4/Thunderbird3.3/SeaMonkey2.1),youcanhidetheadmittedlyuglyfileelementandpresentyourowninterfaceforopeningthefilepickeranddisplayingwhichfileorfilestheuserhasselected.像这样(使用jQuery):$('a.upload').click(f

javascript - Karma 中的单元测试 : Keypress inside a text Input

有一个简单的html文本输入:testcharacter.init();希望能够在此文本输入内发生的每个按键上运行单元测试,并根据特定键检查它。Javascript文件是:'usestrict';window.testcharacter=window.testcharacter||{};(function(){vartestcharacter=function(k){vars=document.getElementById('inputstring').valueif(s!=null||s.trim()!=""){if(k==65){document.getElementById('r

javascript - Redux 中间件设计 re : return values

所以我刚刚阅读了redux中间件,听起来不错。不过有一件事困扰着我——中间件的返回值。我知道中间件的某些实例会返回一些东西(即redux-promise),而我得到其他中间件(即logging)不会-只是返回next(action)的结果。我的问题是,如果我想使用两个都返回内容的中间件会发生什么——它们肯定会互相破坏,而我只会获得最外层中间件的返回值。express/connect中间件通过让中间件将其“结果”写入req和res对象来解决这个问题,但是解决方案是什么还原?编辑这是我的问题的一个更具体的例子:我有两个中间件:将所有操作延迟3秒分派(dispatch)的中间件。这个中间件返

javascript - Angular : how to get input value without ng-model

我有form动态插入input到DOM(来自其他插件)。有没有办法在没有ng-model的情况下从此输入读取值?[]我看了很多例子,但是到处都有人写关于ng-model...:( 最佳答案 使用监视更改的指令。然后,如果认为有必要,您可以将其分配给您的范围。.directive('watchForChanges',function(){return{link:function(scope,element,attrs){element.on('change',function(e){console.log(e.target.value

javascript - react : componentDidMount + setState not re-rendering the component

我对使用componentDidMount和setState来使用react并努力更新自定义组件相当陌生,这似乎是推荐的做法。下面是一个示例(包括用于获取数据的axiosAPI调用):importReactfrom'react';import{MyComponent}from'my_component';importaxiosfrom'axios';exportdefaultclassExampleextendsReact.Component{constructor(props){super(props);this.state={data:[]};}GetData(){returnax

javascript - 在 input[type=file] 上使用 click() 时出现问题

click()函数有问题。它在Opera中不起作用。我正在尝试使inputtype=fileclickedon另一个元素的onclick事件。我需要设置我的输入type=file元素的样式,因此我将其设置为不可见,并将其替换为简单样式的按钮。现在我希望在单击按钮时单击文件元素。我不能使用jQuery,因为我在我的页面中使用MooTools库作为日历,当我尝试使用jQuery时它会产生冲突。我也尝试使用jQuery.noConflict();来避免冲突,但我做不到,因为我是jQuery的新手。这是我的html代码:这是我的JavaScript代码:functionshow_upload(

javascript - contentEditable + selectAll : Firefox won't allow keyboard input on dynamically generated content

我在使用包含contenteditable="true"属性的动态生成元素的Firefox中遇到问题(其他浏览器似乎工作正常):如果我selectAll(动态地或使用我的鼠标),Firefox将不允许键盘输入。请看我的jsFiddleExample以供引用。这似乎只影响Firefox。$(document).ready(function(){$('.edit').live('dblclick',function(){document.execCommand('selectAll',false,null);});$('#live').append('Thiscontentisgenera

javascript - Angular 2 自定义验证器 : check if the input value is an integer?

在Angular2项目中,我需要验证一些输入。如何轻松检查输入值是否为整数?我尝试使用Number(control.value)为空字段返回0-不好。或parseInt(control.value,10)不考虑空格:如果我有类似的东西:1space0,24=1,024它返回1-它通过了验证器没有错误。Lodash函数如:_.isInteger(control.value)或_.isNumeric(control.value)//每次都返回false-这是预期的,因为输入值是字符串而不是数字。像这样组合方法会创建一个包含许多if/else语句的困惑函数,即便如此,我也不确定我是否得到了所

javascript - Polymer 在按键上获得 paper-input 、核心输入字段的值

我有paper-input元素我可以在释放按键时捕获事件。Polymer("app-input",{ready:function(){this.value=false;},keypressHandler:function(event,detail,sender){console.log("inputChanged");console.log(this.value);}});但只有当焦点从输入字段中移除时,this.value才会更改,因此我无法在按钮被释放时检索元素值。如何在keypressHandler()中获取元素值? 最佳答案

javascript - 如何解析 input[] 值并将它们放入 Javascript 数组中

假设我有这个:如何获取foo形式的数组输入值并将它们放入关联数组/对象中,如下所示:varresult={bar:{name:'blah',age:21}};附言我不想为此使用任何框架。 最佳答案 我需要自己做这个,在找到这个问题后,我不喜欢任何答案:我不喜欢正则表达式,其他人是有限的。您可以通过多种方式获取data变量。当我实现它时,我将使用jQuery的serializeArray方法。functionparseInputs(data){varret={};retloop:for(varinputindata){varval=d