jquery easyui-linkButton获取和设置按钮text并且解决火狐不支持innerText的方法
2014-01-04 12:50
483 查看
<a href="javascript:test" id="btn" class="easyui-linkbutton" iconCls="icon-edit" plain="false">text</a>
function test(){
$('#btn').linkbutton({text:'修改'});//easyui-linkButton设置按钮text
var i=$('#btn').linkbutton();//easyui-linkButton获取按钮text
getFixText();
alert(i[0].innerText);
alert(document.getElenxxxxi("id").innerText);
}
//解决火狐不支持innerText
function getFixText() {
(function(bool) {
function setInnerText(o, s) {
while (o.childNodes.length != 0) {
o.removeChild(o.childNodes[0]);
}
o.appendChild(document.createTextNode(s));
}
function getInnerText(o) {
var sRet = "";
for ( var i = 0; i < o.childNodes.length; i++) {
if (o.childNodes[i].childNodes.length != 0) {
sRet += getInnerText(o.childNodes[i]);
}
if (o.childNodes[i].nodeValue) {
if (o.currentStyle.display == "block") {
sRet += o.childNodes[i].nodeValue + "\n";
} else {
sRet += o.childNodes[i].nodeValue;
}
}
}
return sRet;
}
if (bool) {
HTMLElement.prototype.__defineGetter__("currentStyle", function() {
return this.ownerDocument.defaultView.getComputedStyle(this,
null);
});
HTMLElement.prototype.__defineGetter__("innerText", function() {
return getInnerText(this);
})
HTMLElement.prototype.__defineSetter__("innerText", function(s) {
setInnerText(this, s);
})
}
})(/Firefox/.test(window.navigator.userAgent));
}
function test(){
$('#btn').linkbutton({text:'修改'});//easyui-linkButton设置按钮text
var i=$('#btn').linkbutton();//easyui-linkButton获取按钮text
getFixText();
alert(i[0].innerText);
alert(document.getElenxxxxi("id").innerText);
}
//解决火狐不支持innerText
function getFixText() {
(function(bool) {
function setInnerText(o, s) {
while (o.childNodes.length != 0) {
o.removeChild(o.childNodes[0]);
}
o.appendChild(document.createTextNode(s));
}
function getInnerText(o) {
var sRet = "";
for ( var i = 0; i < o.childNodes.length; i++) {
if (o.childNodes[i].childNodes.length != 0) {
sRet += getInnerText(o.childNodes[i]);
}
if (o.childNodes[i].nodeValue) {
if (o.currentStyle.display == "block") {
sRet += o.childNodes[i].nodeValue + "\n";
} else {
sRet += o.childNodes[i].nodeValue;
}
}
}
return sRet;
}
if (bool) {
HTMLElement.prototype.__defineGetter__("currentStyle", function() {
return this.ownerDocument.defaultView.getComputedStyle(this,
null);
});
HTMLElement.prototype.__defineGetter__("innerText", function() {
return getInnerText(this);
})
HTMLElement.prototype.__defineSetter__("innerText", function(s) {
setInnerText(this, s);
})
}
})(/Firefox/.test(window.navigator.userAgent));
}
相关文章推荐
- 当EditText被视图(按钮等)挡住无法获取焦点的解决方法
- Axure RP Pro - 相关问题 - Button按钮部件不支持设置文字以及解决方法
- ViewPager中嵌套Fragment中的EditText设置requestFocus无法获取焦点的解决方法
- js 通过html()及text()方法获取并设置p标签的显示值
- js 通过html()及text()方法获取并设置p标签的显示值
- 对于TextView 设置 Ellipsize ="End" 无效时的解决方法
- js地址栏获取参数的方法,解决中文乱码问题,能支持中文参数
- input设置为disabled提交后获取不到该值的解决方法
- eWebEditor不支持IE,IE8,IE7,火狐,遨游的解决方法
- js添加的表单在火狐下获取不到数据的解决方法
- Android使用TextView,设置onClick属性无效解决的方法
- 解决ios不支持按钮:active伪类的方法
- AFNetworking 2.0 获取json数据时,返回 NSLocalizedDescription=Request failed: unacceptable content-type: text/html, 解决方法.
- 自定义dialog,并且有Edittext,确定按钮获取Edittext的值
- ListView 在getView()中设置一个item中的TextView的动态显示出现其它的也显示的bug解决方法
- 关于将RadioButtonList的AutoPostBack属性设置为"True"获取子项时候引起回发的问题解决方法
- EditText 设置多行_光标不再首行的解决方法:
- jquery中html()或text()方法获取或设置p标签的值
- jQuery 获取、设置HTML或TEXT内容的两种方法
- 安卓代码中获取dimen设置字体大小setTextSize,会变得比dimen的值还大——解决方法