function EditorDivOpen(a){
$('#'+a).show();
}
function EditorDivClose(a){
$('#'+a).close();
}
function EditorDivFill(a,b){
var init;
if(a == 'smileys'){
init = '<img src="data/img/smileys/sad.png" onclick="EditorTextFill(\':(\');" class="point" alt="smiley"> \
<img src="data/img/smileys/happy.gif" onclick="EditorTextFill(\':)\');" class="point" alt="smiley"> \
<img src="data/img/smileys/angelnot.gif" onclick="EditorTextFill(\'0:=)\');" class="point" alt="smiley"> \
<img src="data/img/smileys/angry.gif" onclick="EditorTextFill(\'=(\');" class="point" alt="smiley"> \
<img src="data/img/smileys/blush.gif" onclick="EditorTextFill(\':@\');" class="point" alt="smiley"> \
<img src="data/img/smileys/cencored.png" onclick="EditorTextFill(\':*\');" class="point" alt="smiley"> \
<img src="data/img/smileys/confused.gif" onclick="EditorTextFill(\':?\');" class="point" alt="smiley"> \
<img src="data/img/smileys/cry.png" onclick="EditorTextFill(\';(\');" class="point" alt="smiley"> \
<img src="data/img/smileys/grin.gif" onclick="EditorTextFill(\':D\');" class="point" alt="smiley"> \
<img src="data/img/smileys/hmm.png" onclick="EditorTextFill(\':|\');" class="point" alt="smiley"> \
<img src="data/img/smileys/hypocrite.gif" onclick="EditorTextFill(\'0=)\');" class="point" alt="smiley"> \
<img src="data/img/smileys/lock.gif" onclick="EditorTextFill(\':x:\');" class="point" alt="smiley"> \
<img src="data/img/smileys/love.gif" onclick="EditorTextFill(\':3\');" class="point" alt="smiley"> \
<img src="data/img/smileys/sunglasses.gif" onclick="EditorTextFill(\'8)\');" class="point" alt="smiley"> \
<img src="data/img/smileys/shifty.gif" onclick="EditorTextFill(\'|)\');" class="point" alt="smiley"> \
<img src="data/img/smileys/shock.gif" onclick="EditorTextFill(\'O_o\');" class="point" alt="smiley"> \
<img src="data/img/smileys/shock.gif" onclick="EditorTextFill(\':o\');" class="point" alt="smiley"> \
<img src="data/img/smileys/sweatingbullets.gif" onclick="EditorTextFill(\'^_^\');" class="point" alt="smiley"> \
<img src="data/img/smileys/tongue.gif" onclick="EditorTextFill(\':p\');" class="point" alt="smiley"> \
<img src="data/img/smileys/tongue.gif" onclick="EditorTextFill(\':P\');" class="point" alt="smiley"> \
<img src="data/img/smileys/wink.gif" onclick="EditorTextFill(\';)\');" class="point" alt="smiley"> \
<img src="data/img/smileys/wry.gif" onclick="EditorTextFill(\'xo\');" class="point" alt="smiley"> \
<img src="data/img/smileys/wry.gif" onclick="EditorTextFill(\'XD\');" class="point" alt="smiley"> \
<img src="data/img/smileys/wry.gif" onclick="EditorTextFill(\'xD\');" class="point" alt="smiley">';
}
else
{
init = '<img src="data/img/buttons/bold.png" onclick="EditorTextFill(\'[b][/b]\');" class="point" alt="bold"> \
<img src="data/img/buttons/italic.png" onclick="EditorTextFill(\'[i][/i]\');" class="point" alt="italic"> \
<img src="data/img/buttons/underline.png" onclick="EditorTextFill(\'[u][/u]\');" class="point" alt="underline"> \
<img src="data/img/buttons/strike.png" onclick="EditorTextFill(\'[s][/s]\');" class="point" alt="strike"> \
<img src="data/img/buttons/link.png" onclick="EditorTextFill(\'[url][/url]\');" class="point" alt="Link"> \
<img src="data/img/buttons/image.png" onclick="EditorTextFill(\'[img][/img]\');" class="point" alt="Image">';
}
init = '<img src="data/img/buttons/remove.png" alt="remove" class="closebutton point" onclick="EditorDivClose(\'edit-content\');">'+ init;
$('#'+b).html(init);
}
function EditorTextFill(msg){
$('#editor-textarea').html() = $('#editor-textarea').html() + msg;
}
<img src="data/img/smileys/happy.gif" alt="smileys" onclick="EditorDivOpen('edit-content'); EditorDivFill('smileys', 'edit-content');" class="point">
<img src="data/img/buttons/bold.png" alt="tags" onclick="EditorDivOpen('edit-content'); EditorDivFill('tags', 'edit-content');" class="point">
<div id="edit-content">
</div>
<textarea cols="60" rows="6" name="message" id="editor-textarea"></textarea><br>
<input type="submit" value=" submit ">
上述代码中的某些功能无效,分别为EditorDivClose()
和EditorTextFill()
。两者都得到错误:
此对象
不支持此属性或方法
两个在第一个$字符。
答案 0 :(得分:2)
没有名为close
的jQuery方法。您需要hide
function EditorDivClose(a){
$('#'+a).hide();
}
要设置html值,请将要设置的值传递给html
方法,如此
function EditorTextFill(msg){
var oldVal = $('#editor-textarea').html();
$('#editor-textarea').html(oldVal + msg);
}
或
function EditorTextFill(msg){
$('#editor-textarea').html(function (i, oldVal) {
return oldVal + msg
});
}
在jQuery documentation website或jqapi.com上阅读一些文档。它会有所帮助。