[英]How to apply Javascript conditionally on a specific css-class only?
[英]How to apply css class for image only
.calendarList {
background-image: url('/resource3/hpsc/common/images/calendar.png');
background-position: 135px 50%;
background-repeat: no-repeat;
cursor:pointer;
}
<input type="text" id="toDatepicker" class="calendarList" name="searchEndDate" size="20" >
这里css类完全适用于输入文本字段,当鼠标悬停在文本字段上时,光标显示手形符号总输入字段,我只显示该图像的手形符号而不是整个文本字段。
我不认为你可能会做什么。
也许您可以将图像添加为常规图像(而不是bg)并使用一些位置:绝对和z-index将其放在文本框的后面或前面。
我想你可以用JavaScript实现它,但这将是一个非常复杂的解决方案。 如果您将图像设置为标签而不是背景图片并将其放置在输入字段的顶部,则会更容易。
<input type="text" id="toDatepicker" class="calendarList" name="searchEndDate" size="20" >
<label for="toDatepicker" id="datepickerLabel>
<img src="/resource3/hpsc/common/images/calendar.png" />
</label>
CSS:
#datepickerLabel {
position:relative;
left:-20px;
cursor:pointer;
}
有关演示,请参见http://jsfiddle.net/tNwTz/ 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.