【发布时间】:2014-04-22 10:53:18
【问题描述】:
我正在动态生成 div,但我想要的是添加一个锚标记,该标记显示一个垃圾图像,用于在特定 div 悬停时删除该特定消息。我写了一个 :hover on class 来添加背景,效果很好,但我也想添加一个锚标签。这是我的代码::
风格
<style>
.mail:hover {
background-color: #cde6f7;
/*background-image: url("/Content/images/Trash.png");*/
}
.mail {
float: left;
width: 100%;
border-bottom: solid 1px #ccc;
padding-bottom: 10px;
margin-top: 3px;
cursor: pointer;
}
</style>
在这里我正在创建动态 div,我想为我悬停的每个 div 添加背景颜色和垃圾图像图像
<script>
success: function (data) {
if (data.MessageData != null) {
var DataDiv = "";
for (var iRow = 0; iRow < data.MessageData.length; iRow++) {
var RowData = data.MessageData[iRow];
var date = new Date(parseInt(RowData.Sent_Date.substr(6)));
var style = '';
if (RowData.IsReceiver_Received == false) {
style = 'color:#0460C7' + '!important ';
}
DataDiv += "<div class='mail' id='" + RowData.pkMessageId + "' onclick=ShowMessage('" + RowData.pkMessageId + "')>";
DataDiv += "<h3 style=" + style + ">" + RowData.Subject + "</h3>";
//<label class='label' style='color:red ! important;'> hi hi hi </label>
DataDiv += "<label style=" + style + "class='clsLbl'> From:" + RowData.Message_From + "</label>";
DataDiv += "<label style=" + style + "class='clsLb2'>" + date.toDateString() + "</label></div>";
}
$("#hdnSearchType").val(1);
$("#hdnUserType").val(1);
}
$("#MessageStore").html('');
$("#MessageStore").html(DataDiv);
},
</script>
【问题讨论】:
-
I want to add an anchor tag also然后继续。有什么问题? -
不,其实我想在 div 的悬停上添加锚标签。
-
this 可能有帮助
标签: javascript jquery html css dom