I'm creating an extension, my first extension to Google Chrome, the extension consists of changing elements of a page and changing things, but I wanted to put a function for a button via onclick
, but it does not work!
Assuming that the site has the following structure HTML:
<button class="one" onclick="funcaoOriginal();">Teste</button>
In the file js
of the extension I have the following:
function minhaFuncao(){
alert('teste');
}
$('.one').attr('onclick','minhaFuncao()');
but does not work !, if so:
$('.one').attr('onclick','alert(\'teste\')');
It works, but I want to put things like $.each
and $.cookie
inside a function and call it by clicking the site button.
How would I do this?