Greasemonkey & jQuery How do I manipulate an Element I just created? -


so i'm trying make little userscript send data server , react answer (by manipulating link added site)

jquery('table.borderlist').after('<a href="#" id="action"><click here derp</a><br />'); 

this works , adds link site bind new element click handler using live() (because seems way work new link (id=action)) looks this:

    jquery('#action').live('click', function() {      jquery.ajax({       type: 'get',       datatype: 'jsonp',       data: 'id=666',       jsonp: 'jsonp_callback',       url: 'url',       success: function (j) {     // in here want change element id=action nothing tried far seems work }});}); 

the basic idea this:

jquery('#action').replacewith('action successful'); 

problem not seem work on elements i've created using greasemonkey script on other element works fine.

appreciate hints in right direction

you try this:

jquery('table.borderlist').after(     $('<a href="#" id="action"><click here derp</a><br />').click(function(){      }) ); 

but example .live should work well. sure id #action unique?


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -