[jQuery] Re: performing actions on single elements with widely used classes
C'mon guys, I posted this on monday and no one has any ideas/ knows hows to help? On Nov 4, 8:44 am, evo [EMAIL PROTECTED] wrote: anyone? On Nov 3, 5:28 pm, Liam Potter [EMAIL PROTECTED] wrote: Hi, I'm having trouble figuring out how I can perform say, a hide animation on adiv, by clicking a button on onediv, which uses aclassused by other divs. *Lets say I have this:* divclass=message a href=#class=deleteDelete/a pMessage text/p /div divclass=message a href=#class=deleteDelete/a pMessage text/p /div divclass=message a href=#class=deleteDelete/a pMessage text/p /div *then the jquery is: *$(a.delete).click(function () { $(.overlay).hide(slow); }); This will hide all the messages, rather then the one I clicked the delete button on. Right now I'm using server side code to give eachdiva unique id, then have the jquery like this var inc = %#Eval(PrimaryKeyID)%; $(a.delete+ inc).click(function () { $(.overlay).hide(slow); }); This works, but it's not the best option, as I need to keep the JS inline and I'd rather be able to seperate it into a .js file, and use it in future projects just by writing the correct html then dropping the js file in the head. If anyone can show me the right way to do this, it would be extremely helpful. - Liam
[jQuery] Re: performing actions on single elements with widely used classes
Try this: $('a.delete').click(function () { $(this).parent().hide('slow'); }); 2008/11/6 evo [EMAIL PROTECTED]: C'mon guys, I posted this on monday and no one has any ideas/ knows hows to help? On Nov 4, 8:44 am, evo [EMAIL PROTECTED] wrote: anyone? On Nov 3, 5:28 pm, Liam Potter [EMAIL PROTECTED] wrote: Hi, I'm having trouble figuring out how I can perform say, a hide animation on adiv, by clicking a button on onediv, which uses aclassused by other divs. *Lets say I have this:* divclass=message a href=#class=deleteDelete/a pMessage text/p /div divclass=message a href=#class=deleteDelete/a pMessage text/p /div divclass=message a href=#class=deleteDelete/a pMessage text/p /div *then the jquery is: *$(a.delete).click(function () { $(.overlay).hide(slow); }); This will hide all the messages, rather then the one I clicked the delete button on. Right now I'm using server side code to give eachdiva unique id, then have the jquery like this var inc = %#Eval(PrimaryKeyID)%; $(a.delete+ inc).click(function () { $(.overlay).hide(slow); }); This works, but it's not the best option, as I need to keep the JS inline and I'd rather be able to seperate it into a .js file, and use it in future projects just by writing the correct html then dropping the js file in the head. If anyone can show me the right way to do this, it would be extremely helpful. - Liam -- Rik Lomas http://rikrikrik.com
[jQuery] Re: performing actions on single elements with widely used classes
this has helped, now just to modify it for the actual script. Thanks Rik Rik Lomas wrote: Try this: $('a.delete').click(function () { $(this).parent().hide('slow'); }); 2008/11/6 evo [EMAIL PROTECTED]: C'mon guys, I posted this on monday and no one has any ideas/ knows hows to help? On Nov 4, 8:44 am, evo [EMAIL PROTECTED] wrote: anyone? On Nov 3, 5:28 pm, Liam Potter [EMAIL PROTECTED] wrote: Hi, I'm having trouble figuring out how I can perform say, a hide animation on adiv, by clicking a button on onediv, which uses aclassused by other divs. *Lets say I have this:* divclass=message a href=#class=deleteDelete/a pMessage text/p /div divclass=message a href=#class=deleteDelete/a pMessage text/p /div divclass=message a href=#class=deleteDelete/a pMessage text/p /div *then the jquery is: *$(a.delete).click(function () { $(.overlay).hide(slow); }); This will hide all the messages, rather then the one I clicked the delete button on. Right now I'm using server side code to give eachdiva unique id, then have the jquery like this var inc = %#Eval(PrimaryKeyID)%; $(a.delete+ inc).click(function () { $(.overlay).hide(slow); }); This works, but it's not the best option, as I need to keep the JS inline and I'd rather be able to seperate it into a .js file, and use it in future projects just by writing the correct html then dropping the js file in the head. If anyone can show me the right way to do this, it would be extremely helpful. - Liam
[jQuery] Re: performing actions on single elements with widely used classes
anyone? On Nov 3, 5:28 pm, Liam Potter [EMAIL PROTECTED] wrote: Hi, I'm having trouble figuring out how I can perform say, a hide animation on a div, by clicking a button on one div, which uses a class used by other divs. *Lets say I have this:* div class=message a href=# class=deleteDelete/a pMessage text/p /div div class=message a href=# class=deleteDelete/a pMessage text/p /div div class=message a href=# class=deleteDelete/a pMessage text/p /div *then the jquery is: *$(a.delete).click(function () { $(.overlay).hide(slow); }); This will hide all the messages, rather then the one I clicked the delete button on. Right now I'm using server side code to give each div a unique id, then have the jquery like this var inc = %#Eval(PrimaryKeyID)%; $(a.delete+ inc).click(function () { $(.overlay).hide(slow); }); This works, but it's not the best option, as I need to keep the JS inline and I'd rather be able to seperate it into a .js file, and use it in future projects just by writing the correct html then dropping the js file in the head. If anyone can show me the right way to do this, it would be extremely helpful. - Liam