I am working on a tampermonkey / greasemonkey script and want to make a ticket ID clickable to search for it.
I already found on Stack Overflow, that I should use .on()
or .live()
to create the listeners.
My problem is, that I am working with an additional script and I don't have the possibility to change to original source code.
What can I do to keep the listeners?
I am working with this single line in this case to replace a 9 digit number, which is not a part of an html attribute:
$(this).html($(this).html().replace(/\b([0-9]{9})\b(?!(?:(?!<\/?[ha].*?>).)*<\/[ha].*?>)(?![^<>]*>)/,'<a href="example.cpm?search=$1" target="_blank">$1</a>'));
$(this)
could be something like this:
<span class="alert">Hehe</span>123456789
with the listener declaration in the head:
$('span.alert').click(function(){
alert($(this).html());
});