JavaScript Reference/Javascript Properties/contentEditable
Версия от 18:30, 25 мая 2010; (обсуждение)
Содержание
"contentEditable" Example
<!--
Example revised from
The Web Programmer"s Desk Reference
by Lazaro Issi Cohen and Joseph Issi Cohen
ISBN: 1593270119
Publisher: No Starch Press 2004
-->
<html>
<body>
<script language="JavaScript">
function function1() {
myP.innerText = "Try to edit this text by overwriting any part of it.";
document.all.myP.contentEditable = "true"; ]
}
function function2() {
myP.innerText = "Try again.";
document.all.myP.contentEditable = "false";
}
function function3(){
alert(document.all.myP.isContentEditable);
}
</script>
<p id="myP">Try to edit this text by overwriting any part of it.</p>
<button onclick="function1();">Make the text editable</button>
<button onclick="function2();">Make the text non-editable</button>
<button onclick="function3();">isContentEditable</button>
</body>
</html>
"contentEditable" is applied to
+----------------+--------------------------------------------------------------+
| Applied_To |<a> <acronym> |
| |<address> <b> |
| |<bdo> <big> |
| |<blockquote> <body> |
| |<button> <center> |
| |<cite> <code> |
| |<custom> <dd> |
| |defaults <del> |
| |<dfn> <dir> |
| |<div> <dl> |
| |<dt> <em> |
| |<fieldset> <font> |
| |<form> <hn> |
| |<i> <input type="button"> |
| |<input type="password"> <input type="radio"> |
| |<input type="reset"> <input type="submit"> |
| |<input type="text"> <ins> |
| |<isindex> <kbd> |
| |<label> <legend> |
| |<li> <listing> |
| |<marquee> <menu> |
| |<nobr> <ol> |
| |<p> <plaintext> |
| |<pre> <q> |
| |<rt> <ruby> |
| |<s> <samp> |
| |<small> <span> |
| |<strike> <strong> |
| |<sub> <sup> |
| |<textarea> <tt> |
| |<u> <ul> |
| |<var> <xmp> |
+----------------+--------------------------------------------------------------+
"contentEditable" Possible Values
Possible Values
true
false.
"contentEditable" Syntax and Note
Note:
Read and write property.
Can the element content be modified.
Syntax:
document.all.elementID.contentEditable = value