In JavaScript can I make a “click” event fire programmatically for a file input element?

前端 未结 28 1329
囚心锁ツ
囚心锁ツ 2020-11-21 06:29

I\'d like to make a click event fire on an tag programmatically.

Just calling click() doesn\'t seem to do anything or at lea

28条回答
  •  难免孤独
    2020-11-21 06:55

    Here is solution that work for me: CSS:

    #uploadtruefield {
        left: 225px;
        opacity: 0;
        position: absolute;
        right: 0;
        top: 266px;
        opacity:0;
        -moz-opacity:0;
        filter:alpha(opacity:0);
        width: 270px;
        z-index: 2;
    }
    
    .uploadmask {
        background:url(../img/browse.gif) no-repeat 100% 50%;
    }
    #uploadmaskfield{
        width:132px;
    }
    

    HTML with "small" JQuery help:

    Just be sure that maskfied is covered compeltly by true upload field.

提交回复
热议问题