繁体   English   中英

搜索文件并使用Javascript显示

[英]Search in a file and display using Javascript

我需要在文件中搜索在输入字段中输入的表达式,然后以div的形式返回结果,该div前后带有n个字符,并且该表达式以粗体显示。 我不知道一旦使用javascript的search()函数如何返回结果,就知道该命令的结果就是位置。 到目前为止,我只有这样:

var length = expr.legth;/*get the length of the expression searched*/
var indexString = docSearched.search(expression);/*get the position of the expression in the document*/

现在我需要这样的东西:

var el = document.getElementById('content'); 
    el.innerHTML = docSearched[indexString];/*display the all the occurence of the searched expression*/

这是我的方法:

string.substring(beginning,end);

暂无
暂无

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

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