[jQuery] Re: on click event does not response
thanks now it is working fine, I will install livequery but does it slow down the site load.
[jQuery] Re: on click event does not response
jQuery did not recognize the element .test because you had not created it yet. You have to bind a click to a new element after you create it. Something like the following: $(#someID).append(a href='#'My Link/ a).find(a:last).click(function(){ // do something... }); On Feb 6, 12:46 pm, Jquery lover [EMAIL PROTECTED] wrote: hi all, I have problem with my code, when I used jquery to append HTML tags to my list the click event of the new tag did not work, so i decide to move to DOM and the same problem appered again. Here is a snapshot of my code //does not response !!! $(.test).click(function(){ $(#content).empty(); return ; }); // creating element $(a div#textbox).click(function(){ var list = document.getElementById(form_list); var list_element = document.createElement(li); var link = document.createElement(a); $(link).attr(class, test); $(link).attr(href, #); var text_val = document.createTextNode(tes tes test); list_element.append Child(text_val); link.appendChild(list_element); list.appendChild(link); return false; });
[jQuery] Re: on click event does not response
The liveQuery plugin takes care of this work for you. -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Giant Jam Sandwich Sent: Wednesday, February 06, 2008 3:55 PM To: jQuery (English) Subject: [jQuery] Re: on click event does not response jQuery did not recognize the element .test because you had not created it yet. You have to bind a click to a new element after you create it. Something like the following: $(#someID).append(a href='#'My Link/ a).find(a:last).click(function(){ // do something... }); On Feb 6, 12:46 pm, Jquery lover [EMAIL PROTECTED] wrote: hi all, I have problem with my code, when I used jquery to append HTML tags to my list the click event of the new tag did not work, so i decide to move to DOM and the same problem appered again. Here is a snapshot of my code //does not response !!! $(.test).click(function(){ $(#content).empty(); return ; }); // creating element $(a div#textbox).click(function(){ var list = document.getElementById(form_list); var list_element = document.createElement(li); var link = document.createElement(a); $(link).attr(class, test); $(link).attr(href, #); var text_val = document.createTextNode(tes tes test); list_element.append Child(text_val); link.appendChild(list_element); list.appendChild(link); return false; });
[jQuery] Re: on click event does not response
THe problem is in the order in which things are happening in your script. If you take a look at the livequery plugin this might help. But, you should apply the click after the DOM has been manipulated. Since DOM is parsed in the beginning of the page load, nothing happens when you add / remove things into it, the click events are gone. A simple reapply of clicks after classes have been added will fix this. On Feb 6, 2008 9:46 AM, Jquery lover [EMAIL PROTECTED] wrote: hi all, I have problem with my code, when I used jquery to append HTML tags to my list the click event of the new tag did not work, so i decide to move to DOM and the same problem appered again. Here is a snapshot of my code //does not response !!! $(.test).click(function(){ $(#content).empty(); return ; }); // creating element $(a div#textbox).click(function(){ var list = document.getElementById (form_list); var list_element = document.createElement (li); var link = document.createElement(a); $(link).attr(class, test); $(link).attr(href, #); var text_val = document.createTextNode(tes tes test); list_element.append Child(text_val); link.appendChild(list_element); list.appendChild(link); return false; });