Javascript 禁用此jquery代码中的链接
我是一个Javascript高手,在下面的代码中尝试禁用一个链接 这是标题链接。每当我单击包含此类的div时,主页就会加载(href=“#”)。我想在不重命名类或销毁函数的情况下禁用链接 我希望有人能在没有进一步信息的情况下提供帮助。这只是负责链接的代码片段 看到这个代码的时候你知道吗Javascript 禁用此jquery代码中的链接,javascript,jquery,css,function,click,Javascript,Jquery,Css,Function,Click,我是一个Javascript高手,在下面的代码中尝试禁用一个链接 这是标题链接。每当我单击包含此类的div时,主页就会加载(href=“#”)。我想在不重命名类或销毁函数的情况下禁用链接 我希望有人能在没有进一步信息的情况下提供帮助。这只是负责链接的代码片段 看到这个代码的时候你知道吗 jQuery(document).ready(function(e) { e(".squareDemo_production").unbind("hover"); e(".squareDemo_produ
jQuery(document).ready(function(e) {
e(".squareDemo_production").unbind("hover");
e(".squareDemo_production").hover(function() {
e(this).find('.squareLitDemo.shape').css('cursor', 'pointer');
e(this).find('.squareLitDemo.shape').on('click', function() {
console.log('ff', e(this).find('.title_link_out').attr('target'))
if (e(this).find('.title_link_out').attr('target') == 'blank') {
var win = window.open(e(this).find('.title_link_out').attr('href'), '_blank');
win.focus();
}
else{
window.location.href = e(this).find('.title_link_out').attr('href');
}
})
我在CSS中尝试了以下内容,但没有成功
.title_link_out {
pointer-events: none!important;
cursor: default!important;
}
要动态禁用
a href
链接,通常使用e.preventDefault()
:
$('.title_link_out').click(function(e) {
e.preventDefault();
});
更多信息可在上找到,请发布JSFIDLE示例,让所有人都能轻松看到问题。