javascript - 重命名没有 id 的按钮文本

标签 javascript jquery html css

我有 html 作为:

<div class="k-button k-upload-button">
<input id="files" name="files" type="file" data-role="upload" autocomplete="off">
<span>Select files...</span>
</div>

上面的 html 文本(标签)我无法更改。

我只想更改文本:

Select files...

收件人:

Select file

为此我尝试了:

$(".k-button.k-upload-button").find("span").text("Select file");

但这并没有奏效。

请帮帮我。我怎样才能更改文本???

编辑 1:

enter image description here

.k-upload-button span:before {
    content: 'Select File';
     position: relative;
     left: 4444px;
    display: inline;
}
.k-upload-button span {
    position: relative;
   left: -4444px;
  display: inline;
}

最佳答案

CSS 解决方案

跨度从视口(viewport)中移除,其伪子元素放回原位。

Have an example!

CSS

.k-upload-button span {
    position: relative;
    left: -9999px;
}
.k-upload-button span:before {
    content: 'Select file';
    position: relative;
    left: 9999px;
}

关于javascript - 重命名没有 id 的按钮文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25360596/

相关文章:

javascript - 从 tinymce 中的浏览器上下文菜单捕获 'Cut' 事件

javascript - 如何查找三维数组的索引

javascript - For in Javascript 不适用于来自 JSON 的事件

jquery - 如何改进我的 Accordion 控件折叠(关闭)代码?

html - 如何将 HTML 复选框放入列表类型的 View 中

javascript - 在javascript中对json对象进行排序

javascript - 如何使用 Angular 获取json对象的名称

jquery - 使用 jQuery.css 在 Internet Explorer 中获取值

html - anchor 标签不可点击?

javascript - 在 <audio> 中使用 Javascript 创建音频