Added text method to dom module
This commit is contained in:
parent
a15ce1102c
commit
fae6542845
11
README.md
11
README.md
@ -87,6 +87,10 @@ Browser support: IE9+, Latest versions of Firefox, Chrome, Safari, Opera
|
|||||||
Use:
|
Use:
|
||||||
$_.dom.each(selector, callback);
|
$_.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.
|
*show: For setting dom elements as visible. Type defaults as "block", can be set with optional second parameter.
|
||||||
Use:
|
Use:
|
||||||
$_.dom.show(selector, [type]);
|
$_.dom.show(selector, [type]);
|
||||||
@ -95,12 +99,17 @@ Browser support: IE9+, Latest versions of Firefox, Chrome, Safari, Opera
|
|||||||
Use:
|
Use:
|
||||||
$_.dom.hide(selector);
|
$_.dom.hide(selector);
|
||||||
|
|
||||||
#attr: Gets, sets, or removes an attribute from a selector.
|
*attr: Gets, sets, or removes an attribute from a selector.
|
||||||
Use:
|
Use:
|
||||||
Set: $_.dom.attr(selector, attributeName, attributeValue);
|
Set: $_.dom.attr(selector, attributeName, attributeValue);
|
||||||
Get: $_.dom.attr(selector, attributeName);
|
Get: $_.dom.attr(selector, attributeName);
|
||||||
Remove: $_.dom.attr(selector, attributeName, null);
|
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
26
kis.js
@ -587,6 +587,32 @@
|
|||||||
{
|
{
|
||||||
return _attr(sel, name, value);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user