gpt4 book ai didi

javascript - 从元素的兄弟元素中选择一个元素

转载 作者:太空宇宙 更新时间:2023-11-04 04:14:16 25 4
gpt4 key购买 nike

我有 4 个输入表单元素,我想从其值已更改(准备上传)的输入兄弟元素中选择一个元素。但我的语法不起作用:

HTML:

<div style="overflow:hidden; position: relative; display: inline-block;" class="fileinput-wrapper">
<div style="background:url(http://localhost/project/assets/images/ajax-loader.gif) no-repeat center center" data-provides="fileinput" class="fileinput fileinput-new">
<div style="width: 200px; height: 130px;background:url(http://localhost/project/assets/images/upload_a_photo.png) no-repeat center center" data-trigger="fileinput" class="fileinput-preview thumbnail">
</div>
</div>
<input type="file" name="photos[]" tabindex="-1" style="opacity: 0; position: absolute; z-index: -1; left: -367.5px; top: 80.9333px;">
</div>

JS:

$("input[type=file]").on('change',function(){
$(this).siblings('.fileinput-preview').css('background','');
});

最佳答案

$("input[type=file]").on('change',function(){
$(this).parents('.fileinput-wrapper').find('.fileinput-preview').css('background','none');
});

关于javascript - 从元素的兄弟元素中选择一个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20246818/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com