使用Jquery将字符串更改为某些修复格式

时间:2018-01-23 06:37:26

标签: php jquery

让Suppos我有字符串

<td> <?=$row['password']?> </td>

返回哪个

<td>123</td>

现在我想隐藏这个

<td>***</td>

对于sollution我尝试将其输入输入密码。所以我想问一下使用JQUERY的任何Sollution

我不想隐藏或显示我只想更改它以修复格式。例如,如果我使用$而不是*,那么所有字符串都将更改为$。

我也在寻找str_replace()。但它没有意义。

3 个答案:

答案 0 :(得分:2)

不建议使用jQuery来屏蔽您的密码。这是使用PHP

的方法
$password = "1234567890";
$password = str_repeat("*", strlen($password)); 

echo '<td>' . $password . '</td>';

文档:http://php.net/manual/en/function.str-repeat.php

答案 1 :(得分:0)

使用css

console.log($('.disc').text());
.disc {
  font-family: "text-security-disc";
  -webkit-text-security: disc;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
  <tr>
    <td class='disc'>123</td>
    <tr>
</table>

答案 2 :(得分:0)

您不需要JQuery,在PHP中,您可以使用str_repeat

<td><?=str_repeat("*", strlen($row['password']));?></td>