您的位置:首页 > Web前端 > JavaScript

常用的一些js方法

2010-11-23 13:53 691 查看
一些常用的js方法,使用这些方法,到是可以节省不少时间

function getObj(id){ return document.getElementById(id); }         //获取对象

function getValue(id)...{ return document.getElementById(id).value; } //获取值

function setValue(id, value)...{ document.getElementById(id).value = value; } //设置值

function setText(id, text)...{ document.getElementById(id).innerHTML = text; }

function getAttributeValue(id, attributeName)

...{return document.getElementById(id).getAttribute(attributeName);}        //取得某属性的值。

function setAttributeValue(id, attributeName, value)

...{return document.getElementById(id).setAttribute(attributeName,value);}  //为某属性設置值。

function getStatus(id)...{ return !(document.getElementById(id).disabled); }//获取状态,是否禁用

function setStatus(id, status)...{ document.getElementById(id).disabled = !status; } //设置状态

function setEnable(id)...{ document.getElementById(id).disabled = false; }//设置状态是否禁用

function setDisable(id)...{ document.getElementById(id).disabled = true; } //設置狀態為禁用

function setFocus(id)...{ document.getElementById(id).focus(); }//設置為當前焦點

function getSelectedIndex(id)...{ return document.getElementById(id).selectedIndex; }

//取得當時選取項索引值

function setSelectedIndex(id, index)...{ document.getElementById(id).selectedIndex = index; }

//設置當時選取項索引值

function addGrid(gridId)...{ igtbl_addNew(gridId, 0); } //新增一列空白(UltraWebGrid控件用)

function selectObj(id)...{ document.getElementById(id).select();}//選中對像,ddl沒有select方法

//WebDateChooser日期控件

function getDateValue(id)...{ return igdrp_getComboById(id).getValue(); }

function setDateValue(id,value)...{ return igdrp_getComboById(id).setValue(value); }

function setDateFocus(id)...{ return igdrp_getComboById(id).focus(); }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: