我正在研究显示错误消息的简单表单,我的问题是当我尝试在警报消息上添加图标时,图标没有显示。我正在使用Feathericons来生成图标。
我制作了一个简单的片段,图标正常显示,但是当我使用 jquery 显示它时,它不起作用。
希望你能帮助我。
谢谢。
$(document).ready(function(){
feather.replace();
$('button').click(function(){
$('.alert').html('<i data-feather="activity"></i>');
});
});Run Code Online (Sandbox Code Playgroud)
<script src="https://unpkg.com/feather-icons@4.10.0/dist/feather.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button>show Icon</button>
<div class="alert"></div>
<hr>
<i data-feather="home"></i>
<i data-feather="alert-circle"></i>
<i data-feather="globe"></i>Run Code Online (Sandbox Code Playgroud)
尝试这个。
<script src="https://unpkg.com/feather-icons@4.10.0/dist/feather.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button>show Icon</button>
<div class="alert"></div>
<hr>
<i data-feather="home"></i>
<i data-feather="alert-circle"></i>
<i data-feather="globe"></i>
<script>
$(document).ready(function(){
feather.replace();
$('button').click(function(){
$('.alert').html('<i data-feather="activity"></i>');
feather.replace();
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9465 次 |
| 最近记录: |