这是我的 HTML:
<div class="box">
<input type="file" name="file-7" id="file-7" class="inputfile inputfile-6" accept="image/png,image/gif,image/jpeg" />
<label for="file-7">
<span>This is test</span>
<strong>Upload photo</strong>
</label>
</div>
我想使用 jquery 清除跨度的文本(如果有)。我已经写好了代码:
$('#file-7').on('change', function(){
var spn = $(this).closest('span');
spn.attr('text','');
});
文本没有被删除。我做错了什么?
最佳答案
你只需要这样做
spn.html('');
我们不需要用变量来写$()
关于javascript - 如何重置最近的跨度对象的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49271170/