0
有一些代码:如何从表中textarea的右侧对齐按钮?
$('.field').live({
mouseenter:
function()
{
old_value=$(this).text();
item_id=$(this).attr('id');
item=$(this).parent('td');
//height=item.attr('height');
height=event.target.parentNode.offsetHeight;
width=event.target.parentNode.offsetWidth;
//$(event.target).replaceWith('<textarea id="current-editor"></textarea>');
//$("#current-editor").height(height-10);
new_value=(old_value=='Not translated') ? '' : old_value;
$(this).empty();
var field="<textarea style='vertical-align: middle; font-family: Helvetica; font-size: 12pt;' id='new_value' name='term'>" + new_value + "</textarea><div id='save_button' class='btn btn-primary' style='float: right' href='#'>Save</div>";
$(this).html(field);
$("#new_value").height(height);
$("#new_value").width(width);
button_id=item_id.split('/')[0];
button_id=button_id.replace(/([!"#$%&'()*+,./:;<=>[email protected]\[\\\]^`{|}~])/g, "\\$1");
$("#"+button_id).show();
},
mouseleave:
function()
{
$(this).empty();
$(this).html(old_value);
$("#"+button_id).hide();
}
}
);
和代码为“田”:
echo "<td width='200' style='vertical-align: middle;'><div class='field' id='".$record['translate']['label_value']."/".$record['language_id']."'>".
strip_tags($record['translate']['coalesce(loc.language_value)'])."</div>";
所以,表格的单元格的这个代码更改文本内容到textarea的,和它的作品。但是我需要在textarea后添加“保存”按钮,它也可以工作。按钮是在新行(因为textarea必须有100%的宽度),但我需要按钮和textarea在同一行。请告诉我,我该怎么做?
很抱歉,但它不工作。我有1个想法:我试图使用这个命令:item.width(item.width()+ 50),但是我需要为class ='abc'的所有项目增加宽度。我该怎么做? – user1517541 2012-07-17 07:32:42
$('。abc')。width(new-width) – vikrantx 2012-07-17 08:10:58