Jquery combines the C # background array to automatically add the link code to the keyword of the article
Source: Internet
Author: User
When we need to read multiple keywords in the background, we can first read the background database into an array (separated by commas (,) when the database adds multiple keywords ):
CopyCodeCode: Public String [] STR; // Add a public array and call jquery again
Protected void page_load (Object sender, eventargs E)
{
String str1 = read database keywords;
STR = str1.split (',');
}
Jquery on the page:
<Html s>
<Head>
<SCRIPT type = "text/JavaScript">
$ (Document). Ready (function (){
<% For (INT I = 0; I <Str. length; I ++) {%>
$ ("# Content" ).html ($ ("# Content" ).html (). replace (/<% = STR [I] %>/g, "<a href = 'HTTP: // www.baidu.com '> <% = STR [I] %> </a> "));
<% }%>
});
</SCRIPT>
</Head>
<Body>
<Div id = "content">
<% = Article%>
</Div>
</Body>
</Html>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.