admin管理员组文章数量:1333658
HTML
<div class="event-image">
<figure>
<img src="<?php echo base_url('assets/images/addimg.png'); ?>" />
<figcaption class="imagcaption">Add Image</figcaption>
</figure>
<input type="file" name="upload" />
</div>
jQuery
$(document).on("click","div.event-image",function(){
$(this).children("input[type=file]").trigger("click");
});
I create above div
in loop, so there will me many divs with class="event-image"
. How to trigger the file of the div on which the user click.
Any help would be great
HTML
<div class="event-image">
<figure>
<img src="<?php echo base_url('assets/images/addimg.png'); ?>" />
<figcaption class="imagcaption">Add Image</figcaption>
</figure>
<input type="file" name="upload" />
</div>
jQuery
$(document).on("click","div.event-image",function(){
$(this).children("input[type=file]").trigger("click");
});
I create above div
in loop, so there will me many divs with class="event-image"
. How to trigger the file of the div on which the user click.
Any help would be great
Share Improve this question edited Dec 1, 2015 at 7:15 Rajesh 25k5 gold badges50 silver badges83 bronze badges asked Dec 1, 2015 at 7:09 Waqar HaiderWaqar Haider 9731 gold badge10 silver badges34 bronze badges 3- 2 Because when you triggering input click on document click. Document click automatically calling again and it repeating this process. So you getting this error. – Manwal Commented Dec 1, 2015 at 7:14
-
You can use
e.stopPropagation()
inside click of file – Rajesh Commented Dec 1, 2015 at 7:16 - i am calling document bcz its ajax uploaded div and without it i am not able to click on it – Waqar Haider Commented Dec 1, 2015 at 7:16
1 Answer
Reset to default 8Use e.stopPropagation()
Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.
Add this:
$("input[type=file]").on("click", function(e){
e.stopPropagation();
})
本文标签: javascriptUncaught RangeError Maximum call stack size exceeded (multiple inputfile )Stack Overflow
版权声明:本文标题:javascript - Uncaught RangeError: Maximum call stack size exceeded (multiple input=file ) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742342988a2456973.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论