[jQuery] Re: Finding id of "this"

2007-04-24 Thread Ⓙⓐⓚⓔ
Yes it would! if you want to set the context it has to be a dom element or a jQuery object. try $('p.newsheader', $('.newsitem')).click(function(){ but aren't all the .newsheaders in a .newsitem? Maybe I'm missing something! On 4/24/07, Shelane Enos <[EMAIL PROTECTED]> wrote: Wouldn't that

[jQuery] Re: Finding id of "this"

2007-04-24 Thread Shelane Enos
Wouldn’t that apply the click to the newsitem div and the p.newsheader and not just the p.newsheader inside each div.newsitem ? I was thinking scope of “within” this (whatever I say this is) context. If there are multiple items that fix the scope, will it be applied for each of those items. On

[jQuery] Re: Finding id of "this"

2007-04-24 Thread Ⓙⓐⓚⓔ
change $('p.newsheader', '.newsitem').click(function(){ to $('p.newsheader , .newsitem').click(function(){ On 4/24/07, Shelane <[EMAIL PROTECTED]> wrote: Sorry, hit the button and the message posted prematurely. Can I do this?: $(function(){ $('p.newsheader', '.newsitem').click(funct

[jQuery] Re: Finding id of "this"

2007-04-24 Thread Shelane
Sorry, hit the button and the message posted prematurely. Can I do this?: $(function(){ $('p.newsheader', '.newsitem').click(function(){ var myid = $(this).attr('id'); $(this).next().load('mynews.lasso?news=' + id); }); }); On Apr 24, 8:03 pm, Shelane <[EMAIL PROTECTED]>

[jQuery] Re: Finding id of "this"

2007-04-24 Thread Shelane
In terms of searching a "scope" I'm not quite sure if this is true: there are many divs with a class of "newsitem". I want to bind a click event to all p.newsheaders within all the newsitems divs. So, this repeats for each story: My News Header Content will be loaded here the next new

[jQuery] Re: Finding id of "this"

2007-04-20 Thread Brandon Aaron
You can use the jQuery method attr() to get the id attribute of the element. $(this).attr('id'); However, since 'this' is the element and there is a DOM property exposing the id you can get the id from the a tag like this. this.id; So with that knowledge here is how the click hander would loo

[jQuery] Re: Finding id of "this"

2007-04-20 Thread Karl Swedberg
Hi Shelane, I think this should work... $(function(){ $('a.reminder').click(function(){ var divId = '#div_' + $(this).attr('id'); $(divId).toggle(); $(this).blur(); return false; });//end click }); Let me know if it doesn't produce the results you're look

[jQuery] Re: Finding id of "this"

2007-04-20 Thread Shelane
Nevermind. I answered my own question. Duh, I've used .attr before. Here are my changes which work beautifully. Thanks again jQuery for easy unobtrusive js. New function: $(function(){ $(this).find('a.reminder').click(function(){ var myid = $(this).attr('id');