下面是我的代码:
document.getElementById('association-search-popup1').onclick = function ()
{
var myval= document.getElementsByName("AgreementType_1_input")[0].value;
if (myval=== "")
{
$("#association-search-popup1").off('click');
alert("Please select agreement type");
}
};
HTML:需要禁用的锚标记:
<a id="association-search-popup1" style="display: inline-block;"
href="javascript:void(0)" class="associate-and-inherit-link" data-
associatedentityname="Logistics" data-
associatedentityid="1E74AF39-6B99-4685-9C3F-5F47DB47A410" data-
associationname="Logistics" data-associatedmultiplicity="Many"
data-inheritancepriority="2" data-associatedentitydisplayname="Logistics
Contract" data-hasviewpermission="true" data-
metadata_display_name="Logistics" data-
metadata_display_name_plaintext="Logistics" data-
islookup="true" data_lookupentityname="Logistics">
<span>Logistics</span>
<span class="inherit_details_add" style="float: right
!important;"></span>
</a>
在此代码中,当名称 = "AgreementType_1_input" 的下拉列表没有任何值时,它会禁用 id="association-search-popup1" 的锚标记的单击事件处理程序,但是当我从下拉列表中选择一个值后,点击事件仍然被禁用。
任何人都可以帮助我编写它,以便链接仅在满足“如果”条件时禁用,如果条件不满足则启用