jquery怎么给div下的a标签添加背景图片?

jquery怎么给div下的a标签添加背景图片?,第1张

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />

<title>显示背景</title>

<script type="text/javascript" src="http://www.sz886.com/js/jquery-1.9.1.min.js"></script>

<script type="text/javascript">

$(document).ready(function(e) {

$.each($("#PagingView a"),function(index,item){

switch($(item).text()){

case "First":

$(item).css({"color":"#ff0","background":"url(logo.png)"})

break

case "Next":

$(item).css({"color":"#f00","background":"url(logo.png)"})

break

case "Last":

$(item).css({"color":"#0f0","background":"url(logo.png)"})

break

}

})

})

</script>

</head>

<body>

<div id="PagingView" style="width:500pxheight:500px">

<a href="javascript:" style="height:100pxwidth:100pxdisplay:block">First</a>

<a href="javascript:" style="height:100pxwidth:100pxdisplay:block">Next</a>

<a href="javascript:" style="height:100pxwidth:100pxdisplay:block">Last</a>

</div>

</body>

</html>

需要准备的材料有:电脑,浏览器,HTML编辑器

1、首先,打开HTML编辑器并创建一个新的HTML文件,比如index。html,写出的基本问题代码。

2、 在<button>标签的索引。style="background: url(small2.png)宽度:150 px高度:60px "。

3、当浏览器运行索引时。HTML页面中,按钮成功添加了图像。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11824691.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存