0
此代碼是在僞jquery,但我如何使它作爲jQuery代碼?修改jquery到服務器端的鏈接true/false toggleClass
我需要此選項來打開或關閉圖標,具體取決於管理頁面的選擇,然後在其他頁面上以靜態標記狀態顯示此選擇。
因此,這兩個片段可否修改爲將第二個片段的切換操作包含到第一個片段中?
我需要它與C#一起工作,因爲後端將用C#編寫。
我淘淨修改這樣的代碼,因爲我不知道自己的jQuery,我需要獲得幫助它...:/
//first snippet
$('a').click(function(evt) {
evt.preventDefault();
var link = $(this).attr('href');
$.ajax({
method: post,
url: '/link-tracking',
data: {
href: link
}
});
}).done(function(url) { // pass the url back to the client after you incremented it
window.location = url;
});
//second snippet
$('.verify').click(function() {
\t var id = $(this).parents('div').attr('id');
\t $(this).toggleClass('verified');
$.post('/page.html', {
'verified': $(this).hasClass('verified'),
'id': id
},
function(data) {
\t if (data.verified) {
\t $(this).toggleClass('verified'); \t \t \t \t
\t \t }
//some sort of update function here
});
});
_「是否可以修改它們以將第二個代碼段中的切換操作包含到第一個代碼段中?」_第一個代碼段中應包含哪部分第二個代碼段?或者應該將第二個片段包含在第一個片段中? – guest271314
@ guest27134嗯,我不知道如何一起實現它們。我希望div的切換動作發生在//第二個代碼片段中,因此如果有辦法將兩者浸入其中? – Krys
使用相同的'.verify'選擇器? – guest271314