0
我是jQuery的新手。预览未加载按键
我创建了一些东西,如当我点击add
按钮时显示textarea,并在textarea中输入要显示预览的数据。
但预览无法工作
HTML:
<div id='TextBoxesGroup'>
<div id="TextBoxDiv1">
<label>Textbox #1 :</label>
<input type='textbox' id='textbox1'>
</div>
</div>
<div id="add_comment_box"></div>
<input type='button' value='Add Button' id='addButton'>
<input type='button' value='Cancel Button' id='canButton'>
的JavaScript:
$(document).ready(function() {
var commentNode = $('#lp-comment');
//$(' #live-preview-form textarea').bind('blur keyup',function()
commentNode.keypress(function (event) {
alert('test');;
commentNode.text($('#comment').val());
commentNode.html($('#lp-comment').html().replace(/\n/g, '<br />'));
});
$("#addButton").click(function() {
// $('#add_comment_box').css('display','block');
var newTextBoxDiv = $(document.createElement('div')).attr("id", 'form').hide();
// newTextBoxDiv.after().html('<label>Textbox # : </label> <input type="text" name="textbox" id="textbox" value="" >');
newTextBoxDiv.after().html(
'<div id="live-preview-form" class="lp-block">' +
'<textarea name="comment" id="comment" class="input" rows="10"></textarea>' +
'</div>' +
'<div id="live-preview-display" class="lp-block">' +
'<div id="lp-comment">' +
'</div>');
newTextBoxDiv.appendTo("#add_comment_box").slideDown();
// $("#TextBoxesGroup").append(newTextBoxDiv);
});
$("#canButton").click(function() {
$('#form').slideUp(function() {
$('#form').remove();
});
return false;
});
});
http://jsfiddle.net/nGfh4/看到这个链接 – 2013-02-23 10:28:27
欢迎来到StackOverflow!你能对你的问题更具体一点吗?你越具体,我们就越容易帮助你! – 2013-02-23 10:30:22
@crynix jsfiddle.net/nGfh4看到这个链接 – 2013-02-23 10:31:55