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 4/24/07 8:36 PM, "?ⓐⓚⓔ" <[EMAIL PROTECTED]> wrote:
> change
> $('p.newsheader', '.newsitem').click(function(){
> to
> $('p.newsheader , .newsitem').click(function(){
>
>
>
>
> On 4/24/07, Shelane <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote:
>>
>> 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]> wrote:
>>> > 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:
>>> >
>>> > <div class="newsitem">
>>> > <p class="newsheader">My News Header</p>
>>> > <div class="newscontent">Content will be loaded here</div>
>>> > </div>
>>> > the next news story will be the same format.
>>> >
>>> > Can I do this?:
>>> >
>>> > $(function(){
>>> > $('p.newsheader', '.newsitem').click(function(){
>>> >
>>> > });
>>> >
>>> > On Apr 20, 10:38 am, "Brandon Aaron" <[EMAIL PROTECTED]
>>> <mailto:[EMAIL PROTECTED]> > wrote:
>>> >
>>>> > > 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 <http://this.id> ;
>>> >
>>>> > > So with that knowledge here is how the click hander would look.
>>> >
>>>> > > $(function(){
>>>> > > $(this).find('a.reminder').click(function(){
>>>> > > $('#div_' + this.id <http://this.id> ).toggle();
>>>> > > this.blur()
>>>> > > return false;
>>>> > > });//end click
>>> >
>>>> > > });
>>> >
>>>> > > I also just used the DOM method blur instead of the jQuery blur()
>>>> > > method (which actually just calls the DOM method blur()). Since you
>>>> > > have the DOM element and not doing anything else with it, it makes
>>>> > > more sense to just use the DOM method. Saving on typing too. :)
>>> >
>>>> > > You can also write your selector like this:
>>> >
>>>> > > $('a.reminder', this).click(function() {
>>> >
>>>> > > The second parameter is the scope in which jQuery should run the
>>>> selector.
>>> >
>>>> > > --
>>>> > > Brandon Aaron
>>> >
>>>> > > On 4/20/07,ShelaneEnos <[EMAIL PROTECTED]> wrote:
>>> >
>>>>> > > > I apologize if this solution is posted, but I searched and trying to
get
>>>>> > > > through hundreds of results is a bit painful.
>>> >
>>>>> > > > So I have these titles: Create Reminder, Create Hold Status, Change
>>>>> State.
>>>>> > > > I want to bind a click event to all of them which will toggle the
>>>>> show/hide
>>>>> > > > attribute of a corresponding div.
>>> >
>>>>> > > > So I have this:
>>> >
>>>>> > > > $(function(){
>>>>> > > > $(this).find('a.reminder').click(function(){
>>>>> > > > $(this).toggle();
>>>>> > > > $(this).blur();
>>>>> > > > return false;
>>>>> > > > });//end click
>>>>> > > > });
>>> >
>>>>> > > > However, in this function I'm toggling the title link itself, which
>>>>> is NOT
>>>>> > > > what I want. I want to toggle the corresponding div. so, the
>>>>> titles look
>>>>> > > > like this in html:
>>> >
>>>>> > > > <a href="#" class="reminder" id="areminder">Create Reminder</a>
>>> >
>>>>> > > > I would like to use the id ("areminder") in this case to now toggle
>>>>> the div
>>>>> > > > "div_areminder". How do I find the id of each of these a tags to
apply
>>>>> > > > toggle like this:
>>> >
>>>>> > > > find id method
>>>>> > > > $('#div_' + idofatag).toggle();
>>> >
>>>>> > > > ??
>>> >
>>>>> > > > That's my question. That you very much. Have a nice day.
>>
>
>