禁用超链接 [英] Disable Hyperlink
问题描述
我有两个超链接
var create = dojo.create("div",{
id:"create_links",
className:"iconRow1",
innerHTML:"<a class='popupLink' href='javascript:openCreateUserDialog()'>Create </a> <span>|</span><a href='javascript:openFileUploadDialog()'>Batch </a>"
}
通过这一行,显示两个超级链接
By this line two Hyper Links are shown
我的要求是,点击批量超链接,我想禁用创建超级链接。
My requirement is that , on click of the Batch Hyper Link , i want to disable the Create Hyper Link .
请告诉我该怎么做?
推荐答案
一个解决方案是添加一个替换另一个链接的方法,一个 span
标签具有相同的内容,并从每个方法调用该方法 openCreateUserDialog
和 openFileUploadDialog
。该方法可能如下所示:
One solution would be to add a method that replaces the other link with a span
tag with the same content, and call that method from each of the methods openCreateUserDialog
and openFileUploadDialog
. The method could look something like this:
function disableLink(linkId) {
var link = document.getElementById(linkId);
if (link) {
var label = document.createElement('span');
label.innerHTML = link.innerHTML;
link.parentNode.replaceChild(label, link);
}
}
这将需要你给每个链接一个ID,然后在用户单击其中一个链接时,将其他链接的ID作为参数调用 disableLink
方法。
This would require you to give each of your links an ID and then calling the disableLink
method with the ID of the other link as a parameter when the user clicks one of the links.
以下是一个例子: http://jsfiddle.net/2AXQS/
这篇关于禁用超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!