Chrome extensions: Content script (jQuery) in Youtube does not work properly
- by Fabian
I have this:
$(document).ready(function() {
$("button.yt-uix-expander-arrow").attr("id", "yt-uix-expander-arrow");
$("#yt-uix-expander-arrow").mouseover(function() {
alert("Hello");
});
});
injected into Youtube. Using right click inspect element, the <button class="yt-uix-expander-arrow"> has a id="yt-uix-expander-arrow" attribute successfully added to it. However the mouseover event does not trigger. However if I were to change $("#yt-uix-expander-arrow").mouseover() to $(".yt-uix-expander-arrow").mouseover() it works.
That's very unusual, because the #yt-uix-expander-arrow id has already been added to the button element. I tested it out on Facebook, adding a id to a class and doing a mouseover() event on the ID and it works.
Any idea?