更改登录屏幕的占位符文本

问题描述 投票:1回答:1

我们LMS的登陆页面:https://rainforrentlms.litmos.com/account/Login

我们希望在LMS的主题设置屏幕中使用自定义CSS选项或自定义Javascript选项,将占位符文本从用户名调整为员工编号。

当我检查元素时,这就是我提取的内容:

<input class="first-focus form-control input-lg" id="Username" name="Username" placeholder="Username" required="true" type="text" value="">

在StackOverflow上阅读了很多帖子之后,我推测我应该使用Javascript,因为我们已经成功地使用了Javascript来调整过去的其他内容。

这是我们LMS的自定义Javascript框中已有的现有代码段:

<script type="text/javascript">
$(document).ready(function() {
 checkContainer();
});
function checkContainer () {
 if($('#SendEmail').is(':visible')){ //if the container is visible on the page
 $("#SendEmail").attr('checked', false); //Un-checks the checkbox using CSS ID
 } else {
 setTimeout(checkContainer, 50); //wait 50 ms, then try again
 }
}
</script>

我猜测的代码可以工作并需要插入:

$('Username').attr('placeholder','Employee Number');

我不确定这是否正确,我已经尝试在标题内部的顶部添加它,并且我暂时尝试将其全部插入后暂时删除其他代码,似乎都没有工作。

=========编辑#1 ===========所以这里是我尝试使用你的建议把它放在文档准备部分的代码,也没有任何影响。

<script type="text/javascript">
$(document).ready(function() {
 $('#Username').attr('placeholder','Employee Number');
 checkContainer();
});
function checkContainer () {
 if($('#SendEmail').is(':visible')){ //if the container is visible on the page
 $("#SendEmail").attr('checked', false); //Un-checks the checkbox using CSS ID
 } else {
 setTimeout(checkContainer, 50); //wait 50 ms, then try again
 }
}
$('#Username').attr('placeholder','Employee Number');
</script>
<script type="text/javascript">
$('#Username').attr('placeholder','Employee Number');
</script>
javascript input field placeholder
1个回答
2
投票

你在#之前错过了Username,所以它应该是:

$('#Username').attr('placeholder','Employee Number');

#告诉jQuery使用id="Username"查找元素,而不是<Username>元素。

© www.soinside.com 2019 - 2024. All rights reserved.