使用 javascript 重命名输入中的文本(每点更改 space)
Rename text (change space per point) in input with javascript
看这个:我给这个文件充电..它显示如下
我需要像这样重命名它:
我想按句点自动重命名空格,并删除其他字符,例如 [,()!;'\[\]}{=]
老实说,我没有脚本,因为我不知道该怎么做,我有一个,但那是一场灾难哈哈;我打破了所有 html :/
我只需要修改输入中的文本。 javascript 或 jquery 中的脚本
我澄清一下,文本总是不同的
I leave you a jsfiddle https://jsfiddle.net/qwertyip/j4dcsL7n/12/
希望你能帮到我,问好
我不确定您何时要修改该值,但这会为您更新该值:
// Get a reference to the element in question
let renameThese = Array.from(document.querySelectorAll("input[name^='rename']"));
// Loop through all the elements to be renamed
renameThese.map(el =>
// Replace the spaces with periods and remove all the other characters.
el.value = el.value.replace(/\ /g, '.').replace(/[\[\]\{\}\(\)\;\!\;\'\=]/g, ''));
<table id="list-files" class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th width="35">
<div class="checkbox-custom checkbox-default">
<input type="checkbox" id="select-all-files" checked="">
<label for="select-all-files"></label>
</div>
</th>
<th>File</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="checkbox-custom checkbox-default"><input name="files[]" checked="" type="checkbox" value="2"><label></label></div>
</td>
<td class="pt-none pb-none">
<div>
<div class="pull-left mt-xs mr-xs">PDF Shaper Professional v8.9 (2-click run) / </div>
<div style="overflow:hidden"><input class="form-control input-sm m-none" style="background-color: transparent" type="text" name="rename[2]" value="PDF S[]{}haper Professional v8.9 (2-click run).exe"></div>
</div>
</td>
<td>17.2 MiB</td>
</tr>
<tr>
<td>
<div class="checkbox-custom checkbox-default"><input name="files[]" checked="" type="checkbox" value="2"><label></label></div>
</td>
<td class="pt-none pb-none">
<div>
<div class="pull-left mt-xs mr-xs">PDF Shaper Professional v8.9 (2-click run) / </div>
<div style="overflow:hidden"><input class="form-control input-sm m-none" style="background-color: transparent" type="text" name="rename[2]" value="PDF S[]{}haper Professional v8.9 (2-click run).exe"></div>
</div>
</td>
<td>17.2 MiB</td>
</tr>
</tbody>
</table>
注意:如果您在想更新值时发表评论,请发表评论并进行更新,否则,请继续。
看这个:我给这个文件充电..它显示如下
我需要像这样重命名它:
我想按句点自动重命名空格,并删除其他字符,例如 [,()!;'\[\]}{=]
老实说,我没有脚本,因为我不知道该怎么做,我有一个,但那是一场灾难哈哈;我打破了所有 html :/ 我只需要修改输入中的文本。 javascript 或 jquery 中的脚本 我澄清一下,文本总是不同的
I leave you a jsfiddle https://jsfiddle.net/qwertyip/j4dcsL7n/12/
希望你能帮到我,问好
我不确定您何时要修改该值,但这会为您更新该值:
// Get a reference to the element in question
let renameThese = Array.from(document.querySelectorAll("input[name^='rename']"));
// Loop through all the elements to be renamed
renameThese.map(el =>
// Replace the spaces with periods and remove all the other characters.
el.value = el.value.replace(/\ /g, '.').replace(/[\[\]\{\}\(\)\;\!\;\'\=]/g, ''));
<table id="list-files" class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th width="35">
<div class="checkbox-custom checkbox-default">
<input type="checkbox" id="select-all-files" checked="">
<label for="select-all-files"></label>
</div>
</th>
<th>File</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="checkbox-custom checkbox-default"><input name="files[]" checked="" type="checkbox" value="2"><label></label></div>
</td>
<td class="pt-none pb-none">
<div>
<div class="pull-left mt-xs mr-xs">PDF Shaper Professional v8.9 (2-click run) / </div>
<div style="overflow:hidden"><input class="form-control input-sm m-none" style="background-color: transparent" type="text" name="rename[2]" value="PDF S[]{}haper Professional v8.9 (2-click run).exe"></div>
</div>
</td>
<td>17.2 MiB</td>
</tr>
<tr>
<td>
<div class="checkbox-custom checkbox-default"><input name="files[]" checked="" type="checkbox" value="2"><label></label></div>
</td>
<td class="pt-none pb-none">
<div>
<div class="pull-left mt-xs mr-xs">PDF Shaper Professional v8.9 (2-click run) / </div>
<div style="overflow:hidden"><input class="form-control input-sm m-none" style="background-color: transparent" type="text" name="rename[2]" value="PDF S[]{}haper Professional v8.9 (2-click run).exe"></div>
</div>
</td>
<td>17.2 MiB</td>
</tr>
</tbody>
</table>
注意:如果您在想更新值时发表评论,请发表评论并进行更新,否则,请继续。