一些常用的HTML标签

空格

nbsp;

长传图片在上面实时显示

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片预览示例</title>
    <style>
        .image-preview {
            max-width: 100%;
            max-height: 300px;
        }
    </style>
</head>
<body>
<input type="file" id="input-image" accept="image/*">
<img id="image-preview" class="image-preview" src="#" alt="预览图片" style="display:none;">

<script>
    document.getElementById('input-image').addEventListener('change', function (event) {
        var file = event.target.files[0];
        var reader = new FileReader();

        reader.onload = function (e) {
            var imagePreview = document.getElementById('image-preview');
            imagePreview.src = e.target.result;
            imagePreview.style.display = 'block';
        };

        if (file) {
            reader.readAsDataURL(file);
        } else {
            document.getElementById('image-preview').style.display = 'none';
        }
    });
</script>
</body>
</html>

表格序号自增

//tr开始主动加一
$(function(){
        //$('table tr:not(:first)').remove();
        var len = $('table tr').length;
        for(var i = 1;i<len;i++){
            $('table tr:eq('+i+') td:first').text(i);
        }
 
});
posted @ 2023-03-25 20:57  “生产队的驴”  阅读(10)  评论(0编辑  收藏  举报