Используйте ЛИБО jQuery ИЛИ Vanilla JS
.off, скорее всего, не то, что вам нужно
Однако, не видя вашего кода, я могу только отключить его или заблокировать щелчок , если есть другой обработчик событий, вам может потребоваться установить и протестировать атрибут данных в другом коде, который вы нам не показали
Использование classList.toggle для отключения
jQuery:
const $ICMAgreement = $("[name=ICMAgreementType_1_input]").eq(0);
const toggleLink = function() {
$("#association-search-popup1").toggleClass("isDisabled", $ICMAgreement.val() === "")
};
$ICMAgreement.on("change", toggleLink)
.change(); // on load
.isDisabled {
pointer-events: none;
/* use e.preventDefault() instead if you want */
cursor: not-allowed;
/* the not-allowed cursor to show */
color: currentColor;
opacity: 0.5;
text-decoration: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select name="ICMAgreementType_1_input">
<option value="">Please select</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<a id="association-search-popup1" style="display: inline-block;" href="javascript:void(0)" class="associate-and-inherit-link" ... >
<span>Logistics</span>
<span class="inherit_details_add" style="float: right
!important;"></span>
</a>
То же ваниль
const ICMAgreement = document.querySelector("[name=ICMAgreementType_1_input]");
const toggleLink = function() {
document.getElementById("association-search-popup1").classList.toggle("isDisabled", ICMAgreement.value === "")
}
ICMAgreement.addEventListener("change", toggleLink)
toggleLink(); // on load
.isDisabled {
pointer-events: none;
color: currentColor;
cursor: not-allowed;
opacity: 0.5;
text-decoration: none;
}
<select name="ICMAgreementType_1_input">
<option value="">Please select</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<a id="association-search-popup1" style="display: inline-block;" href="javascript:void(0)" class="associate-and-inherit-link" ...>
<span>Logistics</span>
<span class="inherit_details_add" style="float: right
!important;"></span>
</a>
$("#association-search-popup1").on('click', function(e) {
if ($("[name=ICMAgreementType_1_input]").eq(0).val() === "") {
console.log("Nope. Click not happening")
e.preventDefault();
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select name="ICMAgreementType_1_input">
<option value="">Please select</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<a id="association-search-popup1" style="display: inline-block;" href="javascript:void(0)" class="associate-and-inherit-link" ... >
<span>Logistics</span>
<span class="inherit_details_add" style="float: right
!important;"></span>
</a>
document.getElementById("association-search-popup1").addEventListener('click', function(e) {
if (document.querySelector("[name=ICMAgreementType_1_input]").value === "") {
console.log("Nope, click not happening");
e.preventDefault();
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select name="ICMAgreementType_1_input">
<option value="">Please select</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<a id="association-search-popup1" style="display: inline-block;" href="javascript:void(0)" class="associate-and-inherit-link" ... >
<span>Logistics</span>
<span class="inherit_details_add" style="float: right
!important;"></span>
</a>