日期:2014-05-16  浏览次数:20369 次

js控制获得焦点与失去焦点样式
	
 function focusInput(focusClass, normalClass) {
        var elements = document.getElementsByTagName("input");
        for (var i = 0; i < elements.length; i++) {
            if (elements[i].type != "button" && elements[i].type != "checkbox" && elements[i].type != "radio" 
            && elements[i].type != "submit" && elements[i].type != "reset") {
                elements[i].className = normalClass;
                elements[i].onblur = function() {
                    this.className = normalClass;
                };
                elements[i].onfocus = function() {
                    this.className = focusClass;
                };

            }
        }
    }
 //页面一加载就应用这种样式
 window.onload = function () {
        focusInput('input50_focus', 'input50');
        focusTextarea('textarea50_focus','textarea50');
    }

 //创建第一个td
	   var td = tr.insertCell(1);
       td.innerHTML = "<input type=\"hidden\" name=\"summaryId"+num+"\"  id=\"summaryId"+num+ "\" /> <input type=\"hidden\" name=\"personInChargeId"+num+"\"  id=\"personInChargeId"+num+"\"/>"+
       " <input type=\"text\" name=\"personInChargeName"+num+"\" id=\"personInChargeName"+num+"\"  />";
       focusInput('input50_focus','input50');


方式一:
td.style.cssText="BORDER-BOTTOM:   #4a75ce   1px   solid";    

方式二:
td.className="样式";  

//虽然我玉树临风,风流倜傥,有广阔的胸怀和强健的臂腕,有杨过的冷酷、韦小宝的多情、郭靖的纯朴、张无忌的优柔、乔峰的豪爽,但是你若是喜欢我可以跟我说的呀,我一定会认真考虑的一 一!