如果我有像
这样的链接列表<a href="http://www.mywebsite.com/Scripts/xx.pdf>link1</a>
<a href="http://www.mywebsite.com/Scripts/xx1.pdf>link2</a>
如何在页面加载(jquery)中删除网站地址,以便最后只有相对网址
<a href="/Scripts/xx.pdf>link1</a>
<a href="/Scripts/xx1.pdf>link2</a>
答案 0 :(得分:1)
共享代码段以删除基本网址here:
(define (dispatch m)
(let ((count 0))
(cond ((eq? m 'withdraw) withdraw) ; Increments count
((eq? m 'deposit) deposit) ; Increments count
((eq? m 'balance) balance-return)
((eq? m 'transaction) count) ; "count" on this line should return the value
(else (error "Unknown request -- MAKE-ACCOUNT"
m)))))
您可以将其与function RemoveBaseUrl(url) {
/*
* Replace base URL in given string, if it exists, and return the result.
*
* e.g. "http://localhost:8000/api/v1/blah/" becomes "/api/v1/blah/"
* "/api/v1/blah/" stays "/api/v1/blah/"
*/
var baseUrlPattern = /^https?:\/\/[a-z\:0-9.]+/;
var result = "";
var match = baseUrlPattern.exec(url);
if (match != null) {
result = match[0];
}
if (result.length > 0) {
url = url.replace(result, "");
}
return url;
}
方法的回调函数一起使用:
.attr()
<强> Working Demo 强>
答案 1 :(得分:0)
请查看下面的代码段。出于演示目的,我使用了从OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Request.PhysicalApplicationPath + "Resources/cars_db.accdb");
conn.Open();
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandText = "INSERT INTO Users (Username, Password, Email, Address, Question, Answer) VALUES ('" + txtUsernameRP.Text + "','" + txtPasswordRP.Text + "','" + txtEmailRP.Text + "','" + txtAddressRP.Text + "','" + txtQuestionRP.Text + "','" + txtAnswerRP.Text + "')";
int i = cmd.ExecuteNonQuery(); -- **Breaks here and says syntax error**
开始的href
。希望它会对你有所帮助。
首先点击“打印Href”按钮,查看原始http://stacksnippets.net/
。然后点击“从Href删除基座”按钮,这将更改href
以从所有href
标记中删除网站地址。然后再次单击“打印Href”按钮以查看修订后的<a>
href
$(document).ready(function(){
$("#printHref").click(function(){
$("#link1href").text($($("a")[0]).attr("href"));
$("#link2href").text($($("a")[1]).attr("href"));
});
$("#changeHref").click(function(){
$("a").each(function(){
var websiteName = window.location.host;
var partToReplcae = "http://"+websiteName;
$(this).attr("href",$(this).attr("href").replace(partToReplcae,""));
});
});
});