Dynamic tag generation question.

Asked 2 years ago, Updated 2 years ago, 75 views

// Please fill it out here
<!DOCTYPE html> <!-- Mobile Web Page Settings --> .fileBox .fileName {display:inline-block;width:190px;height:30px;padding-left:10px;margin-right:5px;line-height:30px;border:1px solid #aaa;background-color:#fff;vertical-align:middle} .fileBox .btn_file {display:inline-block;border:1px solid #000;width:100px;height:30px;font-size:0.8em;line-height:30px;text-align:center;vertical-align:middle} /.fileBox input[type="file"] {position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}/

Additional Browse

var uploadFile = $('.sss .fileBox .uploadBtn'); uploadFile.on('change', function(){ if(window.FileReader){ var filename = $(this)[0].files[0].name; } } else { var filename = $(this).val().split('/').pop().split('\').pop(); } $(this).siblings('.fileName').val(filename); });

var fileCnt = 1; $('.btn_img_add').click(function() {

var img_html ='\ \ \ Browse\ \ ';

$(".sss").append(img_html);

fileCnt++; })

Why can't I get the file value for the dynamic generation? I'm so curious

jquery file forms dynamic

2022-09-22 12:41

1 Answers

When you create a dynamic generation, you must bind the event to the domain in order for the JavaScript event to occur properly. After the append, give the event back to the new dom.


2022-09-22 12:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.