I'm working in edit mode (contenteditable=true), I need to call the function inside the link but it does not respond.
Can be done? I need it
Note: I canceled the buttons to call the function, but it does not work either:
My HTML:
<body>
<a href="link.html"><i class="miniButton">Inside</i>LINK Think</a>
<div id="message"></div>
<i class="miniButton">out link button</i>
</body>
Mi Code:
$("body").on("click",'a', function() {
return false;
});
$(document).on("click",'.miniButton', function() {
$("#message").html("Good Job");
});
Mi jsFiddle:
中调用函数答案 0 :(得分:2)
您应该尝试此操作,而不是返回false。
import { Observable, interval, range, concat } from 'rxjs';
答案 1 :(得分:1)
所有锚点元素上的$("a").on("click", function(event) {
event.preventDefault();
});
阻止了click事件到达其内部的.miniButton元素。如果您需要阻止导航,则可以在事件上使用return false
而不是完全将其取消:
preventDefault()
$("body").on("click",'a', function(e) {
e.preventDefault()
});
$(document).on("click",'.miniButton', function() {
$("#message").html("Good Job");
});
body{padding: 3em ;}
a{
color: White;
background: SteelBlue;
padding: 1em;
border-radius: 4px;
text-decoration: none;
}
i{
color: White;
background: Black;
padding: 6px;
margin-right: 10px;
}
#message{
margin-top: 2em;
margin-bottom: 2em;
background: #FFEEAA;
padding: 1em;
width: 160px;
height: 60px;
}