如何用JS语句显示图片?

JavaScript011

如何用JS语句显示图片?,第1张

需要准备的材料分别有:电脑、html编辑器、浏览器。

1、首先,打开html编辑器,新建html文件,例如:index.html。

2、在index.html中的<script>标签,输入js代码:$('body').append('<img src="https://www.baidu.com/img/bd_logo1.png" />')。

3、浏览器运行index.html页面,此时图片被js成功显示到页面上。

1.在同一个div中,编写如下图所示的一段代码,并在这段代码中设置dive的宽度和高度,以便文本具有特定的范围。

2.找到背景,如下图所示,添加背景后的图像作为背景图案。

3.在后台添加url()。为了连接图像,在url中写入背景图像的路径。

4.你可以把你最喜欢的图片根据你的个人喜好。你必须把正确的路径写在这里。

5.这样,保存后的文本将覆盖在图片的顶部。

让两张图片position:absolute

然后让The F 显示 , The P 不显示

$('#for-the_f').click(function(){

$('#the_f').css('display','block')

$('#the_p').css('display','none')

})

$('#for-the_p').click(function(){

$('#the_p').css('display','block')

$('#the_f').css('display','none')

})