我正在使用对话框将对话框中的一些值添加到textarea,但我确定有些错误,以下内容无效。它甚至没有向我显示警报
function makecode(formName,editor) {
$('#codeEditor').dialog({
height: 250,
width: 400,
modal: true,
resizable: false,
title: "Create Code for the FAQ Question",
show: {effect: "blind",duration: 1000},
hide: {effect: "explode",duration: 1000},
beforeclose: function() {
$("#answer").val($.this.attr('id').text());
alert(this.attr('id').text());
$(this).dialog("close");
}
});
document.forms[formName].elements[editor].focus();
}
<div id="codeEditor" style="display:none;height:200px;">
<div align="left" class="showborders" contenteditable="true" id="sendDataBack"></div>
<br />
<div align="left">The above block is editable, write any code inside it and it will be displayed inside the FAQ's Answers</div>
</div>
<input type="button" name="bCode" value=" Code " onClick="makecode('formFaqs','answer');" alt="Use this button to insert Code." title="Use this button to insert Code.">
答案 0 :(得分:0)
好的,如果有人来这里寻找答案我解决了:这就是我做的事情
function makecode(formName,editor) {
$('#codeEditor').dialog({
height: 250,
width: 400,
modal: true,
resizable: false,
title: "Create Code for the FAQ Question",
show: {effect: "blind",duration: 1000},
hide: {effect: "explode",duration: 1000},
close: function() {
var addData = $("#sendDataBack").text();
var textbox = $("#answer");
textbox.val(textbox.val() + '<div class="code">' + addData + '</div>');
$(this).dialog("close");
}
});
document.forms[formName].elements[editor].focus();
}
如果有人有更好的方法,请更新答案