我一直在尝试使用[jQuery HighlightTextarea](https://github.com/garysieling/jquery-highlighttextarea),但遇到以下问题,下面的文本出现在textarea上方。是什么原因造成的?
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="/jquery/highlighttextarea.js"></script>
<script src="/jquery/highlighttextarea.css"></script>
<title>Page Title</title>
</head>
<body>
<div>
<textarea cols="50" rows="5">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque at massa non erat convallis vulputate molestie nec dui. Donec auctor blandit nibh quis luctus. Donec tincidunt auctor consequat.</textarea>
</div>
<script>
$('textarea').highlightTextarea({
words: ['Lorem ipsum', 'vulputate']
});
</script>
</body>
</html>
输出:
虽然我期望从文档中获得帮助:
答案 0 :(得分:0)
您没有正确添加CSS,
更改:
<script src="/jquery/highlighttextarea.css"></script>
收件人:
<link rel="stylesheet" type="text/css" href="jquery.highlighttextarea.css"/>