用jQuery修改background图片平铺方式

<html>
<head>
<title>测试css修改</title>
</head>
<body>
<img src="1.png" />
<input type="button" id="myButton" value="按钮" onclick="changeCss()" />
<script src="jquery-1.8.0.js" type="text/javascript"></script>
<script type="text/javascript">

function changeCss() {
//alert("hello");
$("#myButton").val("提交中……")
$("#myButton").css("width", "100px")

$("#myButton").css({ "background": "url(1.png) repeat-x", "overflow": "hidden" });
}


</script>
</body>

</html>

以上例子为,通过jQuery,修改按钮背景图片。

特别需要注意的是,repeat-x后面千万不能有分号;

原文地址:https://www.cnblogs.com/Tpf386/p/6202208.html