[jQuery] Re: Selector question

2009-07-29 Thread Hector Virgen
Within your click function, this refers to the element that was clicked
(in this case, either #bridge1 or #bridge2). You can then get the
(immediate) children of that element that match the selector 'p' and toggle
that.

$('#bridge1,#bridge2').click(function(){
   $(this).children('p').toggle();
   return false;
});

--
Hector


On Wed, Jul 29, 2009 at 1:23 PM, lukas animod...@gmail.com wrote:


 How can I pick an id element (here #bridge1,#bridge2) and toggle its
 child (here a p element) without actually using the id element as
 parent?
 'this  p' apparently does not work.

 $('#bridge1,#bridge2').click(function(){
$('this  p').toggle();
return false;
 });

 Thanks for your help!


[jQuery] Re: Selector question

2009-07-29 Thread Brett Ritter

On Wed, Jul 29, 2009 at 4:23 PM, lukasanimod...@gmail.com wrote:
 How can I pick an id element (here #bridge1,#bridge2) and toggle its
 child (here a p element) without actually using the id element as
 parent?
 'this  p' apparently does not work.

$(this).children(p)

It only checks immediate children (as with ).  For further
descendants use .find() instead.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org


[jQuery] Re: Selector question

2009-07-29 Thread lukas

Thank you for your immediate response, Hector and Brett! I love the
jquery group!


[jQuery] Re: selector question

2009-06-09 Thread mkmanning

$(div:not(#+pid+) form span).css(background-color,yellow);

On Jun 9, 8:19 am, squalli2008 m...@paskell.co.uk wrote:
 Hi,

 Im trying to select all spans in divs containing forms that dont have
 a certain id

 $(div:not([id='#'+pid]) form span).css(background-color,
 yellow);

 This selects all spans regardless of the ID.. Any suggestions
 would be great!

 Thanks in advance...


[jQuery] Re: selector question

2009-06-09 Thread Danny

You probably don't want the '#' character in there:
$(div:not(+pid+) form span).css(background-color,yellow);

On Jun 9, 11:45 am, mkmanning michaell...@gmail.com wrote:
 $(div:not(#+pid+) form span).css(background-color,yellow);

 On Jun 9, 8:19 am, squalli2008 m...@paskell.co.uk wrote:

  Hi,

  Im trying to select all spans in divs containing forms that dont have
  a certain id

  $(div:not([id='#'+pid]) form span).css(background-color,
  yellow);

  This selects all spans regardless of the ID.. Any suggestions
  would be great!

  Thanks in advance...


[jQuery] Re: selector question

2009-06-09 Thread mkmanning

Yes you do, if you want to filter by ID. Unless the variable pid =
#some_id.

On Jun 9, 1:29 pm, Danny d.wac...@prodigy.net wrote:
 You probably don't want the '#' character in there:
 $(div:not(+pid+) form span).css(background-color,yellow);

 On Jun 9, 11:45 am, mkmanning michaell...@gmail.com wrote:



  $(div:not(#+pid+) form span).css(background-color,yellow);

  On Jun 9, 8:19 am, squalli2008 m...@paskell.co.uk wrote:

   Hi,

   Im trying to select all spans in divs containing forms that dont have
   a certain id

   $(div:not([id='#'+pid]) form span).css(background-color,
   yellow);

   This selects all spans regardless of the ID.. Any suggestions
   would be great!

   Thanks in advance...


[jQuery] Re: Selector Question from a newb

2009-01-15 Thread Karl Swedberg

On Jan 15, 2009, at 1:06 PM, John wrote:


This has probably been asked several times on the list but I'm having
trouble finding a resolution.


Yes. In fact, it has been asked frequently. :)

http://docs.jquery.com/Frequently_Asked_Questions#Why_doesn.27t_an_event_work_on_a_new_element_I.27ve_created.3F

I've just updated the doc to include mention of jQuery 1.3's new  
live() and die() methods.




--Karl

Karl Swedberg
www.englishrules.com
www.learningjquery.com



[jQuery] Re: Selector Question from a newb

2009-01-15 Thread Balazs Endresz

If you are using 1.3 it might be related to this:
http://dev.jquery.com/ticket/3848

Anyway, if you select by ID then you don't need any other selectors as
IDs are unique.

On Jan 15, 7:06 pm, John li...@johndubchak.com wrote:
 This has probably been asked several times on the list but I'm having
 trouble finding a resolution.

 I have a simple problem where I dynamically add html to a div when the
 user clicks a link based on an event handler, which works fine.
 However, I am further trying to bind events to a couple of buttons
 that are part of the dynamic html that has just been added.

 Using the following selector, I am able to view the newly added html
 table and see the input button listed:

 $('#' + parentId + '  #submitForm  table')

 But, nothing is returned when I try to use something similar to get
 the submit button:

 $('#' + parentId + '  #submitForm  table #button_id')

 I've tried a number of different selectors, including '' and '
 ' (space) but can't seem to find it correctly in the DOM.

 Thanks for any help.

 John


[jQuery] Re: Selector Question

2009-01-14 Thread bittermonkey

Got it.  Thanks Mike.  So this code would have made better sense:

$(button:first).click(function(event){alert(this);})


On Jan 13, 5:52 pm, Michael Geary m...@mg.to wrote:
 Do you have Firebug? If not, get it and enable the Console and Script tabs,
 then enter these statements into the console input line, one at a time with
 Enter after each one:

 $(button)

 $(button)[0]

 $( $(button)[0] )

 Each one will log an object to the console log. Click on each of these
 objects to look at its properties.

 You'll find that the first one is a jQuery object - which happens to be an
 array of DOM elements. Take the [0] of that object, as in the second
 expression, and now you have the first DOM element in that array. Since it's
 not a jQuery object, it doesn't have a .bind() method. Instead, it has the
 properties and methods of any other DOM element.

 Now wrap the whole thing in another $() function call, as in the third
 expression, and you're creating a new jQuery object that happens to contain
 the same DOM element as the first one.

 -Mike

  From:bittermonkey

  I'm fairly new to the framework and I've been messing around a bit.
  These below confuses me.

  1.  Why is this snippet not working?  Firefox's error console
  throws an error saying  $(button)[0].bind is not a
  function  $(button)[0].bind(click, function(event){alert(this)});

  2.  And why does this work?
  $($(button)[0]).bind(click, function(event){alert(this)});


[jQuery] Re: Selector Question

2009-01-13 Thread Michael Geary

Do you have Firebug? If not, get it and enable the Console and Script tabs,
then enter these statements into the console input line, one at a time with
Enter after each one:

$(button)

$(button)[0]

$( $(button)[0] )

Each one will log an object to the console log. Click on each of these
objects to look at its properties.

You'll find that the first one is a jQuery object - which happens to be an
array of DOM elements. Take the [0] of that object, as in the second
expression, and now you have the first DOM element in that array. Since it's
not a jQuery object, it doesn't have a .bind() method. Instead, it has the
properties and methods of any other DOM element.

Now wrap the whole thing in another $() function call, as in the third
expression, and you're creating a new jQuery object that happens to contain
the same DOM element as the first one.

-Mike 

 From: bittermonkey
 
 I'm fairly new to the framework and I've been messing around a bit.
 These below confuses me.
 
 1.  Why is this snippet not working?  Firefox's error console 
 throws an error saying  $(button)[0].bind is not a 
 function  $(button)[0].bind(click, function(event){alert(this)});
 
 2.  And why does this work?
 $($(button)[0]).bind(click, function(event){alert(this)});
 



[jQuery] Re: selector question: how many ul above $(this) ?

2008-12-30 Thread pixeline

nevermind, found it!

var thisMenuLevelInt = $thisA.parents('ul').length;



On 30 déc, 17:22, Alexandre Plennevaux aplennev...@gmail.com
wrote:
 hello mates,

 i have a multiple level dropdown menu, the markup is an unordered list
 of the likes:

 ul
 lia href=#me/a
           ullia href=#me/a/li
                      lia href=#me/a
                            ullia href=#me/a/li
                                  lia href=#me/a/li
                                  lia href=#me/a/li
                           /ul
                     /li
                     lia href=#me/a/li
            /ul/li
 lia href=#me/a
              ullia href=#me/a/li
                      lia href=#me/a
                            ullia href=#me/a/li
                                  lia href=#me/a/li
                                  lia href=#me/a/li
                           /ul
                     /li
                     lia href=#me/a/li
            /ul
 /li

 lia href=#me/a/li
 /ul

 Imagine i click in the link 3 levels down the list. Can someone tell
 me how i can find the value 3, meaning, the amount of parent ul?
 i tried

                 var $thisA = $(this);
                 var $thisLI = $thisA.parent();
                 var $thisMenu = $thisLI.parent();
                 var $thisSubmenu = $thisLI.children('ul');

 var thisMenuLevelInt = $thisLI.parents().index($thisMenu[0]);

 but that always returns 0.

 Your help is as usual, *much* appreciated !

 Alexandre


[jQuery] Re: selector question

2008-12-04 Thread MorningZ

If you don't want to manipulate the td's themselves, then you have
to have the content of the td's wrapped in some sort of object so
that you can show/hide it...  something your example HTML doesn't have


On Dec 4, 12:56 pm, clorentzen [EMAIL PROTECTED] wrote:
 Hi --

 I'm trying to hide all the contents from tds within a table *except*
 for the first td in each tr... I don't want to hide the tds,
 just their contents, but I'm having trouble finding the correct
 selector(s) to accomplish this.

 So, for example, if the table is:

 table
 tr
 tdone/td
 tdtwo/td
 tdthree/td
 /tr
 tr
 tdfour/td
 tdfive/td
 tdsix/td
 /tr
 /table

 I'd like to hide the actual *content* two, three, five, and
 six -- for as many tds there are after the first one in each row,
 and for as many rows as there are in the table.

 Thanks in advance!

 --Carl.


[jQuery] Re: selector question

2008-12-04 Thread Charlie Griefer
On Thu, Dec 4, 2008 at 9:56 AM, clorentzen [EMAIL PROTECTED] wrote:


 I'm trying to hide all the contents from tds within a table *except*
 for the first td in each tr... I don't want to hide the tds,
 just their contents, but I'm having trouble finding the correct
 selector(s) to accomplish this.

 table
 tr
 tdone/td
 tdtwo/td
 tdthree/td
 /tr
 tr
 tdfour/td
 tdfive/td
 tdsix/td
 /tr
 /table

 I'd like to hide the actual *content* two, three, five, and
 six -- for as many tds there are after the first one in each row,
 and for as many rows as there are in the table.



$(function() {
$('tr  td:not(:first-child)').css({visibility:'hidden'});
});

-- 
I have failed as much as I have succeeded. But I love my life. I love my
wife. And I wish you my kind of success.


[jQuery] Re: selector question

2008-12-04 Thread Charlie Griefer
On Thu, Dec 4, 2008 at 10:28 AM, Charlie Griefer
[EMAIL PROTECTED]wrote:

 On Thu, Dec 4, 2008 at 9:56 AM, clorentzen [EMAIL PROTECTED]wrote:


 I'm trying to hide all the contents from tds within a table *except*
 for the first td in each tr... I don't want to hide the tds,
 just their contents, but I'm having trouble finding the correct
 selector(s) to accomplish this.

 table
 tr
 tdone/td
 tdtwo/td
 tdthree/td
 /tr
 tr
 tdfour/td
 tdfive/td
 tdsix/td
 /tr
 /table

 I'd like to hide the actual *content* two, three, five, and
 six -- for as many tds there are after the first one in each row,
 and for as many rows as there are in the table.



 $(function() {
 $('tr  td:not(:first-child)').css({visibility:'hidden'});
 });



Altho, to MorningZ's point... that's affecting the tds themselves, and not
specifically the content.

-- 
I have failed as much as I have succeeded. But I love my life. I love my
wife. And I wish you my kind of success.


[jQuery] Re: selector question

2008-12-04 Thread clorentzen

Thanks! The lack of something else wrapping each tds content was
indeed the problem.



On Dec 4, 1:34 pm, Charlie Griefer [EMAIL PROTECTED]
wrote:
 On Thu, Dec 4, 2008 at 10:28 AM, Charlie Griefer
 [EMAIL PROTECTED]wrote:



  On Thu, Dec 4, 2008 at 9:56 AM, clorentzen [EMAIL PROTECTED]wrote:

  I'm trying to hide all the contents from tds within a table *except*
  for the first td in each tr... I don't want to hide the tds,
  just their contents, but I'm having trouble finding the correct
  selector(s) to accomplish this.

  table
  tr
  tdone/td
  tdtwo/td
  tdthree/td
  /tr
  tr
  tdfour/td
  tdfive/td
  tdsix/td
  /tr
  /table

  I'd like to hide the actual *content* two, three, five, and
  six -- for as many tds there are after the first one in each row,
  and for as many rows as there are in the table.

  $(function() {
  $('tr  td:not(:first-child)').css({visibility:'hidden'});
  });

 Altho, to MorningZ's point... that's affecting the tds themselves, and not
 specifically the content.

 --
 I have failed as much as I have succeeded. But I love my life. I love my
 wife. And I wish you my kind of success.


[jQuery] Re: Selector Question

2007-08-25 Thread Joan Piedra
Glad I could help :)

On 8/24/07, Pops [EMAIL PROTECTED] wrote:


 That did it!  Thanks Joan!

 --
 HLS

 On Aug 24, 12:51 am, Joan Piedra [EMAIL PROTECTED] wrote:
  Hey Pops,
  I have not tested this, but should work. Just use the next node.
 
  $('legend').click(function(){
$(this).next().fadeOut(250);
 
  });
 
  On 8/24/07, Pops [EMAIL PROTECTED] wrote:
 
 
 
 
 
   I have HTML like so with a bunch of fieldset tags:
 
   fieldsetlegend[ Title1 ]/legenddiv id='wc1'/div/fieldset
   fieldsetlegend[ Title2 ]/legenddiv id='wc2'/div/fieldset
   ..
   fieldsetlegend[ Titlen ]/legenddiv id='wcn'/div/fieldset
 
   These fade in and out and I had this for the fade out:
 
   $('[EMAIL PROTECTED]').click( function() {
$(this).text().fadeOut(250);
   });
 
   But I don't want to click the div container to fade out, but rather
   the legend, and then fade out the div container that immediately
   follows it..
 
   How do do this using selectors?
 
   I tried this incorrect syntax among other things and it didn't work:
 
   $('legend').click( function() {
   $(this:first-child).fadeOut(250);
   });
 
   Thanks
 
   --
   HLS
 
  --
  Joan Piedra || Frontend webdeveloperhttp://joanpiedra.com/




-- 
Joan Piedra || Frontend webdeveloper
http://joanpiedra.com/


[jQuery] Re: Selector Question

2007-08-23 Thread Joan Piedra
Hey Pops,
I have not tested this, but should work. Just use the next node.

$('legend').click(function(){
  $(this).next().fadeOut(250);
});


On 8/24/07, Pops [EMAIL PROTECTED] wrote:


 I have HTML like so with a bunch of fieldset tags:

 fieldsetlegend[ Title1 ]/legenddiv id='wc1'/div/fieldset
 fieldsetlegend[ Title2 ]/legenddiv id='wc2'/div/fieldset
 ..
 fieldsetlegend[ Titlen ]/legenddiv id='wcn'/div/fieldset

 These fade in and out and I had this for the fade out:

 $('[EMAIL PROTECTED]').click( function() {
  $(this).text().fadeOut(250);
 });

 But I don't want to click the div container to fade out, but rather
 the legend, and then fade out the div container that immediately
 follows it..

 How do do this using selectors?

 I tried this incorrect syntax among other things and it didn't work:

 $('legend').click( function() {
 $(this:first-child).fadeOut(250);
 });

 Thanks

 --
 HLS




-- 
Joan Piedra || Frontend webdeveloper
http://joanpiedra.com/


[jQuery] Re: Selector Question should be easy (continued with online example)

2007-08-16 Thread Karl Swedberg

On Aug 16, 2007, at 4:01 AM, Wizzud wrote:


Your 'jQuery_How_Do_I_not.html' IS working.
If you were to change one of the #ee colours to some completely
different colour you would be able to see the effect of clicking on  
div1.
However, when you click on div2 both click handlers are invoked -  
firstly
for div2, then for div1 - because div2 is within div1, and the  
event is
being propagated (or bubbled, whichever one it is, I'm never sure!)  
which is

not being prevented/cancelled by the div2 click handler.
So it appears that the 'not' is not working, when it actually is!


In which case, you should get along fine if you change the first  
click handler to this:


   $('#apDiv2').click(function(event) {
$(this).css('background-color','#66');
event.stopPropagation();
   });

If that doesn't work for you, let me know and I'll put a demo page up  
somewhere for you.



--Karl
_
Karl Swedberg
www.englishrules.com
www.learningjquery.com






[jQuery] Re: Selector Question should be easy (continued with online example)

2007-08-16 Thread Mitch

Awesome! I got it working and improved it:

http://www.whatbird.com/wwwroot/Components/jQuery_How_Do_I_not3.html

You can now see clicking any div other then div2 unfocuses div2 while
clicking on div2 gives it focus again.

And they said it could not be done!

Thanks for the help.

Mitch

PS Karl I read page 49-52 about event bubbling and it all made sense.
However I just didnt follow the switcher example on page 52 and
instead was trying to remove the handler. I actually got that working
but it didnt prevent the click from bubbling.



[jQuery] Re: Selector question should be easy

2007-08-15 Thread Klaus Hartl


Mike Alsup wrote:

You need to add the '#' for id selection.

$(div :not('#myID'));

Mike


Mike, I'm not so sure about the white space before the colon, 
theoretically div :not(#myId) would select all children of div that do 
not have that particular id?



--Klaus


[jQuery] Re: Selector question should be easy

2007-08-15 Thread Klaus Hartl


Mitch wrote:

Does anyone have a way to select

all divs except one with a specific ID?

I want something like

$(* :not(myID)).click

or

$(div :not(myID)).click

I have tried :not but have not been able to get it to work on IDs,
seems that it just works on elements.

thanks

Mitch





Try

$(div:not('#myID'))


--Klaus



[jQuery] Re: Selector question should be easy

2007-08-15 Thread Mike Alsup

You need to add the '#' for id selection.

$(div :not('#myID'));

Mike


On 8/15/07, Mitch [EMAIL PROTECTED] wrote:

 Does anyone have a way to select

 all divs except one with a specific ID?

 I want something like

 $(* :not(myID)).click

 or

 $(div :not(myID)).click

 I have tried :not but have not been able to get it to work on IDs,
 seems that it just works on elements.

 thanks

 Mitch




[jQuery] Re: Selector question should be easy

2007-08-15 Thread Karl Swedberg

On 8/15/07, Mitch [EMAIL PROTECTED] wrote:


Does anyone have a way to select

all divs except one with a specific ID?


On Aug 15, 2007, at 3:52 PM, Mike Alsup wrote:


You need to add the '#' for id selection.

$(div :not('#myID'));


And you need to close the space between div and :not

$(div:not('#myID'));

--Karl
_
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On Aug 15, 2007, at 3:52 PM, Mike Alsup wrote:



You need to add the '#' for id selection.

$(div :not('#myID'));

Mike


On 8/15/07, Mitch [EMAIL PROTECTED] wrote:


Does anyone have a way to select

all divs except one with a specific ID?

I want something like

$(* :not(myID)).click

or

$(div :not(myID)).click

I have tried :not but have not been able to get it to work on IDs,
seems that it just works on elements.

thanks

Mitch






[jQuery] Re: Selector question should be easy

2007-08-15 Thread John Resig

Yeah, your selector should be:
$(div:not(#myID))

--John

On 8/15/07, Mitch [EMAIL PROTECTED] wrote:

 Does anyone have a way to select

 all divs except one with a specific ID?

 I want something like

 $(* :not(myID)).click

 or

 $(div :not(myID)).click

 I have tried :not but have not been able to get it to work on IDs,
 seems that it just works on elements.

 thanks

 Mitch




[jQuery] Re: Selector question should be easy

2007-08-15 Thread Mike Alsup

Oops.  Thanks for catching that!  (You too, Karl)


On 8/15/07, Klaus Hartl [EMAIL PROTECTED] wrote:

 Mike Alsup wrote:
  You need to add the '#' for id selection.
 
  $(div :not('#myID'));
 
  Mike

 Mike, I'm not so sure about the white space before the colon,
 theoretically div :not(#myId) would select all children of div that do
 not have that particular id?


 --Klaus



[jQuery] Re: Selector question should be easy

2007-08-15 Thread Mitch

I news for all of you, none of these suggestions work. Here is my code
you can run it and see. When I add the last click handler it breaks
the 2nd one and nothing happens. My guess is that is still not the
right selector.

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
html xmlns=http://www.w3.org/1999/xhtml;
head
meta http-equiv=Content-Type content=text/html; charset=utf-8 /
titleUntitled Document/title
script src=../js/jquery.js type=text/javascript/script
script type=text/javascript

$(document).ready(function(){
   /* makes inner div light gray */
   $(#apDiv2).css('background-color','#EE');

   /* makes inner dive dark gray when clicked */
   $('#apDiv2').click(function() {
$(#apDiv2).css('background-color','#66');
   });

   /* this should make inner div light gray when the outer
div apDiv1 is clicked */
   $(div:not(#apDiv2)).click(function() {
 $(#apDiv2).css('background-color','#EE');
   });

/* $(div:not(#apDiv2))  john
   $(div:not('#apDiv2')) klaus*/

});

/script
style type=text/css
!--
#apDiv1 {
position:absolute;
width:761px;
height:372px;
z-index:1;
background-color: #CC;
}
#apDiv2 {
position:absolute;
width:216px;
height:315px;
z-index:1;
left: 32px;
top: 21px;
background-color: #FF;
}
--
/style
/head
body
h1How do I...focus and defocus using not/h1


div id=apDiv1
  div id=apDiv2/div
/div
/body
/html