jquery 結(jié)合C#后臺(tái)的數(shù)組對(duì)文章的關(guān)鍵字自動(dòng)添加鏈接的代碼
更新時(shí)間:2011年07月15日 00:57:35 作者:
jquery 結(jié)合C#后臺(tái)的數(shù)組對(duì)文章的關(guān)鍵字自動(dòng)添加鏈接的代碼,需要的朋友可以參考下。
當(dāng)我們需要在后臺(tái)讀取多個(gè)關(guān)鍵字時(shí),我們可以先把后臺(tái)的數(shù)據(jù)庫(kù)讀取到一個(gè)數(shù)組中(在數(shù)據(jù)庫(kù)添加多個(gè)關(guān)鍵詞時(shí)用“,”隔開(kāi)):
public string[] str; //添加一個(gè)公共數(shù)組一遍jquery調(diào)用
protected void Page_Load(object sender, EventArgs e)
{
string str1 = 讀取數(shù)據(jù)庫(kù)的關(guān)鍵詞;
str=str1.Split(',');
}
頁(yè)面的JQuery:
<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 ><%=str[i] %> </a>"));
<%} %>
});
</script>
</head>
<body>
<div id="content">
<%=文章%>
</div>
</body>
</html>
復(fù)制代碼 代碼如下:
public string[] str; //添加一個(gè)公共數(shù)組一遍jquery調(diào)用
protected void Page_Load(object sender, EventArgs e)
{
string str1 = 讀取數(shù)據(jù)庫(kù)的關(guān)鍵詞;
str=str1.Split(',');
}
頁(yè)面的JQuery:
<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 ><%=str[i] %> </a>"));
<%} %>
});
</script>
</head>
<body>
<div id="content">
<%=文章%>
</div>
</body>
</html>
您可能感興趣的文章:
- jquery中push()的用法(數(shù)組添加元素)
- jquery遍歷數(shù)組與篩選數(shù)組的方法
- jQuery判斷數(shù)組是否包含了指定的元素
- jquery中each遍歷對(duì)象和數(shù)組示例
- jQuery根據(jù)元素值刪除數(shù)組元素的方法
- jquery操作對(duì)象數(shù)組元素方法詳解
- JQuery $.each遍歷JavaScript數(shù)組對(duì)象實(shí)例
- jQuery遍歷對(duì)象、數(shù)組、集合實(shí)例
- jQuery篩選數(shù)組之grep、each、inArray、map的用法及遍歷json對(duì)象
- jQuery中inArray方法注意事項(xiàng)分析
- 關(guān)于jQuery的inArray 方法介紹
- jQuery實(shí)現(xiàn)合并/追加數(shù)組并去除重復(fù)項(xiàng)的方法
相關(guān)文章
jquery.cookie實(shí)現(xiàn)的客戶端購(gòu)物車操作實(shí)例
這篇文章主要介紹了jquery.cookie實(shí)現(xiàn)的客戶端購(gòu)物車操作,結(jié)合實(shí)例形式分析了jQuery基于cookie存儲(chǔ)及操作數(shù)據(jù)實(shí)現(xiàn)購(gòu)物車功能的技巧,需要的朋友可以參考下2015-12-12jquery實(shí)現(xiàn)圖片隨機(jī)排列的方法
這篇文章主要介紹了jquery實(shí)現(xiàn)圖片隨機(jī)排列的方法,涉及jQuery操作圖片的相關(guān)技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-05-05基于jQuery通過(guò)jQuery.form.js插件實(shí)現(xiàn)異步上傳
這篇文章主要介紹了基于jQuery通過(guò)jQuery.form.js插件實(shí)現(xiàn)異步上傳,代碼很詳細(xì),感興趣的小伙伴們可以參考一下2015-12-12jquery.Ajax()方法調(diào)用Asp.Net后臺(tái)的方法解析
本篇文章主要是對(duì)jquery.Ajax()方法調(diào)用Asp.Net后臺(tái)的方法進(jìn)行了介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2014-02-02jQuery插件zTree實(shí)現(xiàn)獲取當(dāng)前選中節(jié)點(diǎn)在同級(jí)節(jié)點(diǎn)中序號(hào)的方法
這篇文章主要介紹了jQuery插件zTree實(shí)現(xiàn)獲取當(dāng)前選中節(jié)點(diǎn)在同級(jí)節(jié)點(diǎn)中序號(hào)的方法,結(jié)合實(shí)例形式分析了屬性插件zTree針對(duì)節(jié)點(diǎn)序號(hào)的相關(guān)操作技巧,需要的朋友可以參考下2017-03-03