js给label加悬停样式

//页面checkboxList radioButtonList 加鼠标out,over样式
function initLableFor(obj)
{
   var lbls = obj.getElementsByTagName("label");
   var a;
   var f = '';
   var lblF = '';
    for(var i =0;i< lbls.length;i++)
    {
        lblF=lbls[i].getAttribute('for')?lbls[i].getAttribute('for'):lbls[i].getAttribute('htmlFor');
        if(lblF.trim() != '')
        {
         a = document.createElement("a");
         a.className = 'tip';
         a.href = 'javascript:void(0);';
         a.onclick="document.getElementById('"+lblF+"').click();"
         a.innerHTML =lbls[i].innerText;
         lbls[i].innerHTML = a.outerHTML;
        }
    }
}
a:hover.tip
{
  border-bottom:gray dotted 1px;text-decoration:none;display:inline-block;
}
a.tip
{
color: #000000;
}
a:link.tip
{
color: #000000;
}
a:visited.tip

color: #000000;
}

你可能感兴趣的:(JavaScript,F#)