我正在尝试这样做,因此当您单击特定的 div 时,它会触发一个输入按钮以打开 uploadcare 小部件。
这是有问题的HTML
<div class="col-md-6 image-preview-single">
<img src="" alt="" class="img-responsive card-shadow hidden">
<div id="logo-upload" class="add-new-short add-new-home-realtor card-shadow-mini btn-file uploader-homicity" style="display:block;text-decoration:none; cursor: pointer;">
<i class="fa fa-photo"/>
<input type="hidden" role="uploadcare-uploader" name="logo" data-upload-url-base="" data-images-only="true" data-crop="150x150" data-clearable="true" id="logo-input">
<div class="uploadcare-widget uploadcare-widget-option-clearable uploadcare-widget-status-ready" data-status="ready">
<div class="uploadcare-widget-dragndrop-area">
Drop a file here
</div>
<div class="uploadcare-widget-status uploadcare-widget-circle uploadcare-widget-circle--canvas">
<canvas width="56" height="56"/>
</div>
<div class="uploadcare-widget-text">
</div>
<div tabindex="0" role="button" class="uploadcare-widget-button uploadcare-widget-button-open">Choose an image</div>
<div tabindex="0" role="button" class="uploadcare-widget-button uploadcare-widget-button-cancel">Cancel</div>
<div tabindex="0" role="button" class="uploadcare-widget-button uploadcare-widget-button-remove">Remove</div>
</div>
</div>
和有问题的Jquery
$( '#logo-upload' ).on( 'click', function() {
$('input#logo-input').click();
});
这是控制台错误
Uncaught RangeError: Maximum call stack size exceeded
at RegExp.exec (<anonymous>)
at n.fn.init (jquery.min.js:2)
at n (jquery.min.js:2)
at HTMLDivElement.<anonymous> (uploadcare.js:72)
at HTMLDivElement.dispatch (jquery.min.js:3)
at HTMLDivElement.r.handle (jquery.min.js:3)
at Object.trigger (jquery.min.js:4)
at HTMLInputElement.<anonymous> (jquery.min.js:4)
at Function.each (jquery.min.js:2)
at n.fn.init.each (jquery.min.js:2)
我在这方面缺少什么?
谢谢