修剪最后一个字符,如果不是数字(trim last character if not a number)
我试图修剪掉字符串中的最后一个字符,如果不是数字例如:“2 + 3-4 *”从那里最后的astrik需要修剪,因为它不是一个数字,我的结果应该是“2+ 3-4" 。 如果用户输入“2 + 3 + 8”,则不需要修剪,因为最后一个是数字。
I'm trying to trim out the last charater from a string if not a number For example : "2+3-4*" From there last astrik needs to be trimmed as it is not a number my result should be as "2+3-4". If user enters "2+3+8" then no needs to trim as the last is number.
原文:https://stackoverflow.com/questions/42351518
更新时间:2022-04-04 14:04
最满意答案
<td contenteditable="true">fooName1</td>
并使用您想要发布表HTML的内容
编辑:
//Listen to blur event in contenteditable td elements $('td[contenteditable=true]').blur(function () { $(this).parent('tr').find('button').removeAttr('disabled'); }); //When a button is clicked find the nearest contenteditable td //element(s) and push their text content to an array, this array is later being posted. $('button').click(function () { var contents = $(this).parents().find('td[contenteditable=true]'); var contentArray = []; for (i = 0; i < contents.length; i++) { contentArray[i] = contents[i].innerHTML; } $.post("test.php", contentArray); });
<td contenteditable="true">fooName1</td>
And use what ever you want to post the table HTML
edit:
//Listen to blur event in contenteditable td elements $('td[contenteditable=true]').blur(function () { $(this).parent('tr').find('button').removeAttr('disabled'); }); //When a button is clicked find the nearest contenteditable td //element(s) and push their text content to an array, this array is later being posted. $('button').click(function () { var contents = $(this).parents().find('td[contenteditable=true]'); var contentArray = []; for (i = 0; i < contents.length; i++) { contentArray[i] = contents[i].innerHTML; } $.post("test.php", contentArray); });
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
将可编辑行添加到表中(Adding Editable Row into Table)[2022-08-22]
问题是添加行函数添加了空值,并没有足够的列来匹配您的定义(日期列表丢失)。 用这个替换你的addrow函数,你会看到它的工作原理... function addrow() { $('#example-checkbox').dataTable().fnAddData( [ 'x', 'c', 'p', 'l', 'a', 'z', 'xyz' ] ); } ALTERNATIVEL ... -
你点击按钮的代码太复杂了。 我通过简化它来减少它。 $(document).ready(function () { $('.editbtn').click(function () { var currentTD = $(this).parents('tr').find('td'); if ($(this).html() == 'Edit') { $.each(currentTD, func ...
-
有角度的可编辑材质表(Angular Editable Material Table)[2023-06-30]
您应该按照以下步骤操作: 用你想存储的数据创建一个类。 我建议你使用lowerCamelCase作为变量: public class Comment { id: number; comment: string; } 使用您指定的类实例化一个新的TableDataSource 。 在你指定的例子中,你正在安装MatTableDataSource : this.dataSource = new TableDataSource([], Comment); // The array is emp ... -
只需将过滤器扩展为不包含mr_id列: $(document).on("click", "#html_master .edit", function() { var $this = $(this); var tds = $this.closest('tr').children().filter(function() { var $thisTd = $(this); return $thisTd.find('.edit').length === 0 && !$thisTd.hasCl ...
-
下面: function deleteRow(mytable) { try { var table = document.getElementById('mytable'); var rowCount = table.rows.length; 您将字符串文字“mytable”传递给getElementById而不是mytable变量的值。 使用变量名而不是文字。 然后在这一行: