删除字符串中的୹字符 - Jquery

时间:2017-09-22 05:19:57

标签: javascript jquery

我有一个包含7列的表,我得到了最后一列的值:

 var chkValue = $(this).closest('th').next('td').next('td').next('td').next('td').next('td').next('td').next('td').text();

例如,值为:" TEST"

当我尝试:

alert(chkValue);

返回

୹୹୹୹୹୹୹୹୹TEST୹୹୹୹୹୹୹

如何删除此୹字符?

6 个答案:

答案 0 :(得分:4)

您可以替换非单词字符的字符。虽然root问题似乎是<?php $stmt = mysqli_prepare($con, "SELECT date, IFNULL(AT,'null') FROM test"); $result = array('date' => array(), 'AT' => array()); if ($stmt) { mysqli_stmt_execute($stmt); mysqli_stmt_bind_result($stmt, $date, $at); while (mysqli_stmt_fetch($stmt)) { $result['date'][] = strtotime($date)*1000; // get unix timestamp in milliseconds $result['AT'][] = (int)$at; $stamp = strtotime($date); // get unix timestamp $time = $stamp*1000; } mysqli_stmt_close($stmt); } ?> 的编码。

document

答案 1 :(得分:1)

替换是要走的路,但你必须知道那是什么字符......

我只是想给你一些建议,简化你的选择并使它与cols的数量无关(可能在将来你必须添加更多的列并且不想打破这个)你可以用...

var chkValue = $(this).closest('th').children('td').last().text();

答案 2 :(得分:0)

这假设你所看到的都是相同的字符(它们看起来都像是正方形,但可能是不同的unicode字符)

var myElement = $(this).closest('th').next('td').next('td').next('td').next('td').next('td').next('td').next('td');
var newValue = myElement.text().replace('୹', '');
myElement.text( newValue );

答案 3 :(得分:0)

你可以使用正则表达式

试试这个:

account.account.template

\ W是单词和数字

专门为您添加:

"୹୹୹୹୹୹୹୹TEST୹୹୹୹୹".replace(/\W/g, '');

答案 4 :(得分:0)

如果您使用的是HTML5,请定义字符集。它可能有助于您解决问题。

<head>
  <meta charset="UTF-8">
</head> 

答案 5 :(得分:0)

试试这个

var unicodeVal = "୹".charCodeAt(0); //get unicode value first

var output = "୹୹୹୹୹୹୹୹୹TEST୹୹୹୹୹୹୹".replace( /./g, function(match)  { return match.charCodeAt(0) == unicodeVal ? "" : match } );

console.log( output );

//simpler approach if there is only one character to be replaced

output = "୹୹୹୹୹୹୹୹୹TEST୹୹୹୹୹୹୹".replace( /./g, function(match)  { return match == "୹" ? "" : match } )

console.log( output );