【发布时间】:2015-07-15 19:07:27
【问题描述】:
首先我想说我不是专家,甚至可能不是 jQuery 的中级用户,感谢任何和所有帮助。
这是我的小问题的模拟:
https://jsfiddle.net/c897enhy/
<a id="someRandomID_hypNotifSentTo_0" class="NotifSent2" href = "#">
this is the text i want to get
</a>
<br>
<a id="someRandomID_hypNotifSentTo_0" class="NotifSent2" href = "#">
this is the text i want to get 2
</a>
<br>
<a id="someRandomID_hypNotifSentTo_0" class="NotifSent2" href = "#">
this is the text i want to get 3
</a>
if ($) {
$(document).ready(function () {
$("a[id*='_hypNotifSentTo_']").live("click", function ($e) {
// Will post list of recipients to be removed from the file
var x = $(this).text();
alert(x);
AjaxSuccessPopulateRecipients("restult");
});
function AjaxSuccessPopulateRecipients(result) {
alert("asdf");
var x = $('#NotifSent2').toString();
alert(x);
var x = $(this).text();
alert(x);
var recipients = $(this).text();
alert("1");
var recipientArr = recipients.split(',');
}
});
}
虽然我可以从“点击”事件中获取活动链接的文本,但我无法从我的第二个函数中获取。
应用程序的工作方式是,第一个函数调用 ajax c# 文件,然后将成功返回到第二个 jquery 函数,其中包含 c# 的一些结果。
我需要将从 c# 返回的结果与单击的超链接内的结果进行比较,但无法从“AjaxSuccess”函数中获取单击的文本。
【问题讨论】:
-
var x = $('#NotifSent2').toString(); var x = $(this).text();这完全没有意义。
标签: javascript c# jquery