S
S
Semyon Kataparov2016-06-25 13:40:41
Google
Semyon Kataparov, 2016-06-25 13:40:41

Chrome extension doesn't read $(),click, how to fix?

On the page I add:

<a href="#" id="savetradeBtn" class="btn btn-primary input-group-addon">Save Trade URL</a>

And the extension doesn't work:
$('#savetradeBtn').click(function() {
        console.log("321");
        savetrade();
    });

How to fix?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
A person from Kazakhstan, 2016-06-25
@LenovoId

is jquery included?
you have #savetradeBtn in jquery and the button is called #savetrade

T
ThunderCat, 2016-06-25
@ThunderCat

Usually "doesn't work" has symptoms,
what does the error console give?
does your console.log("321"); or does it not reach?
where is the piece of code before the call and after the call? Maybe it does not reach here at all for some ifam?
Before and after the handler add console.log("start"); console.log("end");, it will be at least clear whether the code comes here or not.

R
Rou1997, 2016-06-25
@Rou1997

Where and how do you add the element and where is your script? Perhaps you are confusing background script and content script, or you are just adding an element in such a way that the DOM does not have time to line up.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question