我正在尝试将元素的背景设置为no-repeat- 我尝试了以下方式,但它似乎什么都不做,我在哪里出错?它在a链接上显示图像很好.我正在隐藏文本链接text-indent以使其脱离页面(隐藏它)但隐藏它也隐藏了背景图像.有没有办法试图隐藏链接,只显示bg图像?下面是我到目前为止所做的 - 我只需要一些指导来克服这个问题 - 相对较新的jQuery.
<script type="text/javascript"> //Looking for every td a element and alerting it out on page (popup)
$('.AspNet-DataList td a').each(function (index) {
//alert(index + ': ' + $(this).text());
var submitEl = $(".AspNet-DataList td a")
//.parent('.AspNet-DataList td a')
.css('background', 'url(/assets/img/radarstep' + (index + 1) + 'dark.png)', 'backgroundRepeat:', 'no-repeat');
});
Run Code Online (Sandbox Code Playgroud)
当我在firebug中查看它时,td a这是来自jQuery css 的元素.即使no-repeat从这里设置背景也不起作用,在主css文件中我尝试添加高度和宽度 - 似乎不起作用.现在很困惑.
<a id="ctl07_HealthAndSafetyRadarForm_Wizard_SideBarContainer_SideBarList_SideBarButton_5" href="javascript:__doPostBack('ctl00$ctl07$HealthAndSafetyRadarForm_Wizard$SideBarContainer$SideBarList$ctl05$SideBarButton','')" style="background: url("/assets/img/radarstep6dark.png") no-repeat scroll 0 0 transparent;">Review</a>
//main.css
.AspNet-DataList td a {
/*text-indent: -9999em;*/
/*display:block; */
background-repeat: no-repeat;
height: 25px;
width: 25px;
}
Run Code Online (Sandbox Code Playgroud)
Hou*_*ont 22
.css({'background-image' : 'url(/assets/img/radarstep' + (index + 1) + 'dark.png)',
'background-repeat': 'no-repeat'});
Run Code Online (Sandbox Code Playgroud)