ApplyClickableLinkToClass = function(selectedElements) {
// Go through each of the passed in selections and try to apply a link to them
$.each(selectedElements, function() {
var linkElement = $("a:first:not(.do-not-apply-clickable-link)", $(this));
var link = linkElement.attr("href");
if (!IsNullEmptyOrUndefined(link)) {
$(this).click(function(firstLink) {
var divToLink = firstLink;
return function() {
$(divToLink).unbind('click');
if (divToLink.attr("target") != "_blank") {
window.location = link;
return false;
}
};
}(linkElement));
}
});
}
我认为它会在新窗口中打开目标并删除点击事件但在调用时什么都不做,有什么想法吗?
如下所示
var clickable = function () {
ApplyClickableLinkToClass($j(".rc_blueBtn, .rc_whiteBtn:not(.More)"));
};
setTimeout(clickable, 2000);
答案 0 :(得分:0)
你有什么理由在函数调用中使用$ j()而不是简单的$()选择器吗?
ApplyClickableLinkToClass($j(".rc_blueBtn, .rc_whiteBtn:not(.More)"));
答案 1 :(得分:0)
$(this).one("click", function() {
它很容易做你需要的只添加一次点击,然后自动删除。