简体   繁体   中英

How to align button on right from textarea in table?

There is some code:

     $('.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(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g, "\\$1");
                    $("#"+button_id).show();
                },
            mouseleave:
                function()
                {
                    $(this).empty();
                    $(this).html(old_value);
                    $("#"+button_id).hide();
                }
            }
        );

And code for "field":

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>";

So, this code change text content of table's cell to textarea, and it works. But I need to add "Save" button after textarea, and it works too. Button is in new line (because textarea must has 100% width), but I need that the button and the textarea are on the same line. Please, tell me, how can I do it?

将宽度设置为textarea并浮动:向左浮动,请尝试此操作

var field="<textarea style='vertical-align: middle; float:left; width:250px; 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>";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM