本文介绍了jquery - 在打开按钮(从输入=“文件”)被按下后,启动一个功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 html $ b如何在开启*按钮后启动功能? $ b < form id =xxx> < input id =yyytype =file/> < / form> js $(function(){ $ b $('body')。append('jq works< br />>'); $(#xxx)。submit(function() { $ b $('body')。append('start function< br />>'); }); }); jsfiddle $(function(){ $('body')。append( 'jq works< br />'); $(#xxx)。submit(function() { $ ').append('go>>< br />'); )); $(#yyy)。 (){ alert(changed); })。click(function(){ $(this).val()}); }); how can i start a function after the open* button is pressed?html<form id="xxx"> <input id="yyy" type="file" /></form>js$(function(){ $('body').append('jq works <br />'); $("#xxx").submit(function () { $('body').append('start function<br />'); });});jsfiddlehttp://jsfiddle.net/vGBaK/edit:i mean this button -> Thanks in advacene!Peter 解决方案 You can use the change event, it wont fire if the same file is selected but if you also clear on the click event it should work.see this JSFiddle$(function(){ $('body').append('jq works <br />'); $("#xxx").submit(function () { $('body').append('go >> <br />'); }); $("#yyy").change(function(){ alert("changed"); }).click(function(){ $(this).val("") });}); 这篇关于jquery - 在打开按钮(从输入=“文件”)被按下后,启动一个功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-01 11:11