简体   繁体   中英

how to get the form name Javascript

How can i get the input name

Here is my code

document.querySelector('input[type="file"]').addEventListener('change', function(e) {
    alert(e.name); //this is giving me undefined
    uploadFiles('upload.php', this.files, e.name);
}, false);

The 1st input file

<input type="file" class="textbox" name="webinar_image" id="webinar_logo" style="margin-top: 20px;" />

The 2nd input file

<input type="file" class="textbox" name="webinar_logo" id="webinar_logo"  style="margin-top: 20px;" />

该元件可作为this事件处理中,所以使用this.name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM