简体   繁体   English

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

[英]Changing the placeholder text of a login screen

The landing page of our LMS: https://rainforrentlms.litmos.com/account/Login 我们的LMS登陆页面: https : //rainforrentlms.litmos.com/account/Login

We want to use the custom CSS option or the custom Javascript option in our LMS's theme setup screen to adjust the placeholder text from Username to Employee Number . 我们想在LMS的主题设置屏幕中使用自定义CSS选项或自定义Javascript选项将占位符文本从Username调整为Employee Number

When I inspect the element this is what I extract: 当我检查元素时,这就是我提取的内容:

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

After reading many posts here on StackOverflow I surmised that I should use Javascript as we've used that successfully to tweak other things in the past. 在阅读了StackOverflow上的许多文章之后,我推测我应该使用Javascript,因为我们过去已经成功地使用Javascript来进行其他调整。

Here is an existing snippet that is already in our LMS's custom Javascript box: 这是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> 

The code I guessed would work and need to be inserted: 我猜想的代码可以正常工作,需要插入:

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

I'm not sure if that's correct, I've tried adding that at the top just inside the header and I've tried inserting it all by itself after removing the other code temporarily, neither seems to be working. 我不确定这是否正确,我尝试将其添加到标题内的顶部,并尝试在暂时删除其他代码后自行插入所有内容,但似乎都无法正常工作。

=========EDIT #1=========== So here is the code I tried using your suggestion for putting it in the document ready section, also didn't have any effect. =========编辑#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>

You're missing the # before Username , so it should be: 您在Username之前缺少# ,因此应该是:

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

The # tells jQuery to look for an element with id="Username" , as opposed to a <Username> element. #告诉jQuery查找id="Username"的元素,而不是<Username>元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM