[英]Changing the placeholder text of a login screen
我们的LMS登陆页面: https : //rainforrentlms.litmos.com/account/Login
我们想在LMS的主题设置屏幕中使用自定义CSS选项或自定义Javascript选项将占位符文本从Username调整为Employee Number 。
当我检查元素时,这就是我提取的内容:
<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>
您在Username
之前缺少#
,因此应该是:
$('#Username').attr('placeholder','Employee Number');
#
告诉jQuery查找id="Username"
的元素,而不是<Username>
元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.