我有以下代码将简单文本更改为 textarea 字段:
$('.field').live({
mouseenter:
function()
{
title='<?php echo $user_title; ?>';
old_value=$(this).text();
item_id=$(this).attr('id');
item=$(this).parent('td');
height=event.target.offsetHeight;
width=event.target.parentNode.offsetWidth;
new_value=(old_value=='Not translated') ? '' : old_value;
$(this).empty();
var field=(title=='Login') ? "<textarea style='vertical-align: middle; font-family: Helvetica; font-size: 12pt; width: 212px;' id='new_value' name='term'>" + new_value + "</textarea>"
: "<textarea style='vertical-align: middle; font-family: Helvetica; font-size: 12pt; width: 212px;' id='new_value' name='term'>" + new_value + "</textarea><div id='save_button' class='btn btn-primary' href='#'>>></div>";
$(this).html(field);
$("#new_value").height(height);
button_id=item_id.split('/')[0];
button_id=button_id.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g, "\\$1");
$("#"+button_id).show();
$("#new_value").click(function()
{
if (title=='Login')
window.location.replace('<?php echo $fb_url?>');
});
},
mouseleave:
function()
{
$(this).empty();
$(this).html(old_value);
$("#"+button_id).hide();
alert($(this).html());
}
}
);
文本的 div 块:
echo "<td width='250'><div class='field' id='".$record['translate']['label_value']."/".$record['language_id']."'>".
strip_tags($record['translate']['coalesce(loc.language_value)'])."</div>";
它工作正常,但我需要添加额外的 div 块:
echo "<td width='250'><div class='field' id='".$record['translate']['label_value']."/".$record['language_id']."'><div style='width: 200px;'>".
strip_tags($record['translate']['coalesce(loc.language_value)'])."</div></div>";
执行此操作后,我的代码不起作用!它将文本更改为 textarea 字段,但在“mouseleave”事件中它不起作用$(this).empty()
构造!请告诉我,我该如何解决?