Hi all. I have this HTML: <img id="avviso-img" onclick="myfunc1()"> And it works. Now I need to change the onclick (into a function) and I have created this function: function changeOnClick() { $(''avviso-img'').onclick = function() { alert(''aaaa''); myfunc2(); } } But it does not work, javascript console say me that the element has no proprierties (when try to exec that function). Is one of my errors or what ? Thanks. -- Michel ''ZioBudda'' Morelli michel-0oFb7YEmpcLk1uMJSBkQmQ@public.gmane.org Consulenza sistemistica in ambito OpenSource. Sviluppo applicazioni web dinamiche (LAMP+Ajax) Telefono: +39-3939890025 -- Fax: +39-0291390660 http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ajaxblog.it MSN: michel-0oFb7YEmpcIlQMARD/awdg@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Michel, zio budda a écrit :> function changeOnClick() { > $(''avviso-img'').onclick = function() { alert(''aaaa''); myfunc2(); } > } > > But it does not work, javascript console say me that the element has no > proprierties (when try to exec that function). Is one of my errors or > what ?1) When do you call changeOnClick ? 2) Are you certain that at the time of call, your <img> is in the DOM? 3) Are you certain you didn''t mistype the ID either in the <img> or in your script? -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
2007/4/4, Christophe Porteneuve <tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org>:> > > Hey Michel,Hi Cris 1) When do you call changeOnClick ? Before ($(''div_that_contatin_the_img'').show(); 2) Are you certain that at the time of call, your <img> is in the DOM? Yes. It is in the page template. Only in display:hide "style"> 3) Are you certain you didn''t mistype the ID either in the <img> or in > your script?Yes. c&p from page template to my script. Tnx in advance for all. -- Michel ''ZioBudda'' Morelli michel-0oFb7YEmpcLk1uMJSBkQmQ@public.gmane.org Consulenza sistemistica in ambito OpenSource. Sviluppo applicazioni web dinamiche (LAMP+Ajax) Telefono: +39-3939890025 -- Fax: +39-0291390660 http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ajaxblog.it MSN: michel-0oFb7YEmpcIlQMARD/awdg@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi,Mike I guess you should call your changeOnClick function after ($ (''div_that_contatin_the_img'').show(); The Dom couldn''t detect the img when its containing div was in a display:none style,maybe. Try to modify your code and have a try . U can try this: ($(''div_that_contatin_the_img'').show(); $(''avviso-img'').onclick=myfunc2; Vincent. On 4月4日, 下午9时40分, "zio budda" <ziobu...@gmail.com> wrote:> 2007/4/4, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org>: > > > > > Hey Michel, > > Hi Cris > > 1) When do you call changeOnClick ? > > Before ($(''div_that_contatin_the_img'').show(); > > 2) Are you certain that at the time of call, your <img> is in the DOM? > > Yes. It is in the page template. Only in display:hide "style" > > > 3) Are you certain you didn''t mistype the ID either in the <img> or in > > your script? > > Yes. c&p from page template to my script. > > Tnx in advance for all. > > -- > Michel ''ZioBudda'' Morelli mic...-0oFb7YEmpcLk1uMJSBkQmQ@public.gmane.org > Consulenza sistemistica in ambito OpenSource. > Sviluppo applicazioni web dinamiche (LAMP+Ajax) > Telefono: +39-3939890025 -- Fax: +39-0291390660 > > http://www.ziobudda.net ICQ: 58351764http://www.ziobuddalabs.it Skype: zio_buddahttp://www.ajaxblog.it MSN: mic...-0oFb7YEmpcIlQMARD/awdg@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---