添加<a> tag in div but href does not work

时间:2015-10-16 16:41:55

标签: html href

I have following html code but the TasksCount class does not show up as hyperlink. Any idea? I updated the anchor with the wording Link but still no good.

<div id="TaskNotification" style="display: inline!important;  float: left; border; 3px solid #8AC007;PADDING: 5px;"> 
<img id="NotificatioImg" class="n-img" "="" src="../SiteAssets/tasks_sm.png?rev=23" alt="Notification">
<div class="TasksCount">
    <a href="../pages/Tasks.aspx">Link </a> 
</div>
</div>

Here is the CSS

<style>

body {
    font-family:Calibri;
}
#customTaskNotification {
    position:relative;


}
.TasksCount {
    position:absolute;
    top: -.1px; 
    right:-.1px;
    padding:1px 2px 1px 2px;
    background-color:#ff0000; /* orange #ef8913* dark-pink #d06079 */
    color:white;
    font-weight:bold;
    font-size:1.05em;
    width:50%;
    text-align: center;

    border-radius:50%!important;
    box-shadow:1px 1px 1px gray;
}

div.TasksCount:empty { 
    display: none;
}
</style>

Here is the jQuery that populates TasksCount Div

<script type="text/javascript" language="javascript" src="_layouts/15/jquery/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        var rowCount = $(".ms-WPBody tr").not(":has(th)").length;
        var x = $('.ms-WPBody tr td  a').html();
        if(x.indexOf("There are no items") !== -1){        
        rowCount = "";
        }
         $(".rowCount").text(rowCount);
         $(".TasksCount").text(rowCount);
    });     
</script>

3 个答案:

答案 0 :(得分:3)

<div id="TaskNotification" style="display: inline!important;  float: left; border; 3px solid #8AC007;PADDING: 5px;"> 
<img id="NotificatioImg" class="n-img" "=" src="../SiteAssets/tasks_sm.png?rev=23" alt="Notification">
<div class="TasksCount">
    <a href="../pages/Tasks.aspx">Link</a> 
</div>
</div>

锚标记没有文字。只需加入一些文字。

不是您要找的?让我知道:)

答案 1 :(得分:0)

<img class="n-img" "="" src="../SiteAssets/tasks_sm.png?rev=23" alt="Notification">

答案 2 :(得分:0)

因为填充TaskCount会覆盖链接吗? - 试试

$(".TaskCount>a").text(rowCount) 

代替