Added text method to dom module

This commit is contained in:
Timothy Warren 2011-06-29 15:52:33 -04:00
parent a15ce1102c
commit fae6542845
2 changed files with 36 additions and 1 deletions

View File

@ -87,6 +87,10 @@ Browser support: IE9+, Latest versions of Firefox, Chrome, Safari, Opera
Use:
$_.dom.each(selector, callback);
Example : $_.dom.each(".foo", function(e){
$_.dom.text(e, value);
}):
*show: For setting dom elements as visible. Type defaults as "block", can be set with optional second parameter.
Use:
$_.dom.show(selector, [type]);
@ -95,12 +99,17 @@ Browser support: IE9+, Latest versions of Firefox, Chrome, Safari, Opera
Use:
$_.dom.hide(selector);
#attr: Gets, sets, or removes an attribute from a selector.
*attr: Gets, sets, or removes an attribute from a selector.
Use:
Set: $_.dom.attr(selector, attributeName, attributeValue);
Get: $_.dom.attr(selector, attributeName);
Remove: $_.dom.attr(selector, attributeName, null);
*text: Gets or sets the text in between an element's tags
Use:
Set: $_.dom.text(selector, text);
Get: $_.dom.text(selector);

26
kis.js
View File

@ -587,6 +587,32 @@
{
return _attr(sel, name, value);
}
},
text: function(sel, value)
{
var oldValue, set, type;
sel = $(sel);
set = (typeof value !== "undefined") ? true : false;
type = (typeof sel.innerText !== "undefined")
? "innerText"
: (typeof sel.textContent !== "undefined")
? "textContent"
: "innerHTML";
oldValue = sel[type];
if(set)
{
sel[type] = value;
return value;
}
else
{
return oldValue;
}
}
};