harrybowser :
I am writing a Tampermonkey script that should execute some code if a certain button is clicked.
It should check if the clicked button contained an icon before it was clicked. I don't know yet if that's even possible. There are many unique buttons that could be clicked.
This is the button:
<a class="btn aao_btn" id="aao_n">
<span id="available_aao_n" class="label label-danger"><span class="glyphicon glyphicon-remove"></span>
</a>
This is what I got so far. It always returns false
$("a.aao_btn").on("click", function (e) {
if (e.shiftKey) {
// Execute if Shift is pressed while clicking (working)
}
else {
if ( $(this).find("span").hasClass("label_danger") ) {
// Execute if clicked button contains a danger icon
}
else {
// No danger. Currently this is always the outcome.
}
}
return false;
});
Preston PHX :
if ( $(this).find("span.label-danger").length ) {