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>

<a href="#">网站开始的动图</a>,只要把a链接包含住图就行,另外还有一种方法就是在图片上的代码加上onclick,然后加上js跳转页面.你可以试试看.关键是能学到知识.


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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存