Hello. There was a small question. It is necessary to track the click on the link and after the click perform a specific function.

The code was written this way; in the opera, he does his own thing perfectly, but in Mozilla and chrome he does not understand some of the links, although the sample is based on the href attribute.

The links themselves are loaded from the js library (advertising banner rotation).

var link = $('a[href*=marketgid]'); $(link).click(function(){ //запуск кода после клика }); 

An example of the generated link that the user sees.

 <a href="http://marketgid.com/ghits/1657363/i/765/0/pp/1/6/k/?k=25898faSMTM1NTYwNTY0NjU5MDI1ODk4NjY1fbSMThifcSMTNiYTA2NDljZmU%3DfdSMTNiYTA2NGJlMDE%3DfeSfgSZmI%3DfhSMTE3fiSZTM%3DfjSfkSYzE%3DflSfmSZGQ%3DfnSY2E%3DfoSfpSMTE3fqSMjA%3DfrSfsSaHR0cDovL3BpcmF0Y2EvYWRzLnBocA%3D%3DftSaHR0cDovL3BpcmF0Y2EvYWRzLnBocA%3D%3DfuSfvSNGI%3DfwSZmI%3DfxSMWZifySZTI%3DfzSMWE0" target="_blank" style="display: block;" rel="3"><img class="mcimage765" width="200" height="200" src="http://imgg.dt00.net/1657/1657363_vb.jpg"></a> 

    3 answers 3

    If the links are "loaded", then perhaps the following construct will help you:

     $('body').on('click', 'a[href*=marketgid]', function(e){ // ваши махинации тут }) 
    • Thank you very much. Your option works as it should :) - deface

    Read the documentation carefully. The value of the selector must be enclosed in double quotes (if there are single quotes outside):

     var link = $('a[href*="marketgid"]'); 
    • double or single - the result is the same :) Mozilla does not understand all the links js sample. some links work, some don't - deface
    • What version of jQuery, what kind of firefox? - Zhukov Roman
    • jQuery library 1,8,2 Mozilla is also the latest version - deface

    onclick = "" in <a> add and js function code that does what you want to happen.

    • It is interesting to know why the cons in this answer. - Sergey
    • @ Sergey because your answer is not sided with the question. - lampa
    • In general, the question was "It is necessary to track the click on the link and after the click perform a certain function." In the link, I do not see such an attribute, so I do not understand why you think my answer is not involved in the question. - Sergey
    • And you first carefully read the first post as and from where the links come from - deface
    • @ Sergey, by your reasoning, you can also stick C # here :-) - lampa