开发者

Jquery - Start a function after open button (from input="file") is pressed

开发者 https://www.devze.com 2023-01-23 17:32 出处:网络
how can I start a function after the open* button is pressed? html <form id=开发者_开发百科"xxx">

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 />');
        
    });
    
});

jsfiddle http://jsfiddle.net/vGBaK/

edit:

I mean this button ->

Jquery - Start a function after open button (from input="file") is pressed


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("")
    });

});


Here I assume open* button means browse button of your file input box,

 $("#yyy").click(function(){
        //alert("button clicked")
        // write your code
 })
0

精彩评论

暂无评论...
验证码 换一张
取 消