[jQuery] Selector help
I'm using a attribute selector and I want to combine the *= with the ! = on href. Is there any way to do this?
[jQuery] Selector Help
I have a table structure with a multiple rows containing a checkbox input and 4 text inputs with distinct classes. I want to prefill two of the text inputs in the same row where the checkbox is checked. Example code for the first two rows: I need help me crafting the correct selector to focus control onto the text input for the input with class="contact" and class="email". I can write the function to manipulate the attributes but I can't figure out the selector. I haven't had any luck with "prev ~ siblings" or "prev + next". Thanks in advance.
[jQuery] Selector Help
Code: When a link is clicked, I would like to be able to reference the particular parent fieldset element, and not all of them. Something like this doesn't work: $('.link').click(function () { $(this+':parent').BLAHBLAHBLAH(); }); Thanks in advance, the help here is top notch!
[jQuery] Selector help
I'm either making this more difficult than it is, or I'm missing something simple... I have a div that contains a table. Inside that table I have rows with an arbitrary number of cells. The cells may or may not contain a div with a "tasksummary" class. I need to find all the rows that DO NOT have a task summary div, and toggle them. I can easily find the tasksummaries: $("#containerDiv > table > tbody> tr .tasksummary"); But how do I change this to give me the TR's that don't have a task summary div? (note, some of the cells may contain sub tables, so the explicit table>tbody>tr isolates only the main table...) The only method I can see right now is to find the TRs then do a .each() on them and check each row with the .hasClass(). But I'm sure there's an easier way... Thanks for any input. Shawn
[jQuery] selector help
My app has to present some rather lengthy list of choices. Each choice has a checkbox tied to it and multiple choices can be made. When 'editting' the choices, we want to see all available choices, but after editting is done, we only want to see what was selected. I'm stuck coming up with the jQuery selector to display the user choices. Something like this:. $('TR',list).hide().filter(':has([EMAIL PROTECTED])').show(); -- View this message in context: http://www.nabble.com/selector-help-tp17369737s27240p17369737.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Selector help
I am cleaning up some html code and originally i had Profile Settings but the DIV inside the LI was too much so I went with adding the id="profile to but script is no longer working Profile Settings SCRIPT: $("a[class^='edit_']").click(function(){ var url_id = $(this).attr('href'); var x = $(this).attr('id').split('_'); var y = x[0]; var z = x[1]; $("#loading_"+z).show("fast", function() { $("#"+z).slideUp( 1000, function(){ $(".edit_"+z).hide(0.1, function() { $("#"+z).load( url_id , function(){ $("#"+z).slideDown( 1000, function() { $("#loading_"+z).hide(function(){ $("#"+z).fadeTo("fast", 1, function() { $("#"+z).fadeIn("slow"); }); }); }); return false; }); }); }); }); }); Do i eed to edit the selecot as li#? Dave
[jQuery] Selector help
I'm pretty new to Javascript/ jQuery, so this is really bugging me. I'm trying to get the height of an h1 that is a sibling to this. The value for the variable h1Height, however, returned as null in the console in Firebug. Perplexed, I tried console.logging ('this'+'+h1') to see what it was interpreted as. It brought back this+h1, which should select an h1 adjacent to this (which is a div). Javascript h1Height = $('this'+'h1').height(); What went wrong?
[jQuery] Selector Help
How would I go about adding class to the li in this set up? all some none $('a.filter').click(function(){ $(???).addClass('active'); }); Thanks Dave
[jQuery] jQuery Selector Help
Hi, Can some1 please explain this in detail to me? I am confused on the selector part $(''). // add list to ul var list = $('').attr ('class',_imageLoadClassName).appendTo('ul#'+_imgContainerId); Thanks!
[jQuery] Selector help needed
Here's my code: $(document).ready(function(){ $('#menulinks a').hover(function(){ setTimeout(function(){ $(this).stop().animate({ top : '40px', paddingTop : '40px' }); }, 1000); }); }); Before I added a timeout, (this) sufficed. With the timeout set, (this) did not select the hovered link. I tried another selector and it worked fine. How can I specify (this) for this situation? -- View this message in context: http://www.nabble.com/Selector-help-needed-tp23289341s27240p23289341.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Selector help needed
Hi All, This is my DOM structure: First Name: Middle Name: First Name: Middle Name: ... Questions: 1) how can I select the value Garry? I tried $('tr.child1 td input').eq(1).value But it does not work 2) How can I reset all values of input fields of tr.child2 without cycling through? Any help? -- View this message in context: http://www.nabble.com/Selector-help-needed-tp17508515s27240p17508515.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Selector help needed
with the markup like:i want to add a class "active" to , Link 2 (line 4), or links that have inner a.active links. how can i do it with jquery or even pure css?
Re: [jQuery] Selector Help
$('a.filter').click(function(){ $(this).parent().addClass('active'); }); Dave Maharaj :: WidePixels.com wrote: How would I go about adding class to the li in this set up? all some none $('a.filter').click(function(){ $(???).addClass('active'); }); Thanks Dave
Re: [jQuery] Selector Help
Try this: $('a.filter').click(function(){ $(this).parent().siblings('li').removeClass('active'); $(this).parent('li').addClass('active'); }); Maurício -Mensagem Original- De: Charlie Para: jquery-en@googlegroups.com Enviada em: domingo, 29 de novembro de 2009 03:56 Assunto: Re: [jQuery] Selector Help ... Dave Maharaj :: WidePixels.com wrote: How would I go about adding class to the li in this set up? all some none ...
Re: [jQuery] Selector Help
Even better : $('a.filter').click(function() { $(this).closest('ul').children().removeClass('active').end().end().closest('li').addClass('active'); }); Michel Belleville 2009/11/29 Mauricio (Maujor) Samy Silva > Try this: > > $('a.filter').click(function(){ > $(this).parent().siblings('li').removeClass('active'); > $(this).parent('li').addClass('active'); > }); > > Maurício > > -Mensagem Original----- > *De:* Charlie > *Para:* jquery-en@googlegroups.com > *Enviada em:* domingo, 29 de novembro de 2009 03:56 > *Assunto:* Re: [jQuery] Selector Help > ... > > Dave Maharaj :: WidePixels.com wrote: > How would I go about adding class to the li in this set up? > all > some > none > > ... > > > >
Re: [jQuery] Selector Help
That's a nice solution. Let's make it easier to follow with some indentation: $('a.filter').click(function() { $(this) .closest('ul') .children() .removeClass('active') .end() .end() .closest('li') .addClass('active'); }); The basic indentation rules we're following here are: * Put each method call on a line by itself, with the "." at the beginning of the line. (You can put more than one call on the same line, but only when they don't change the selection.) * Where a method creates the jQuery object or changes its element selection, indent the next line. * Where .end() is called, un-indent that line. You could even go overboard on readability and add the missing .end() calls at the very end: $('a.filter').click(function() { $(this) .closest('ul') .children() .removeClass('active') .end() .end() .closest('li') .addClass('active') .end() .end(); }); Now this looks a lot like the way we indent blocks in JavaScript and other languages. Each .closest() or .children() call is matched up with its own .end() call - as is the initial $(this) - and the indentation indicates the code affected by each of those calls. It's more customary to omit those trailing.end() calls, but with or without them, the indentation is a great help in visualizing the structure of a complex chain. -Mike On Sun, Nov 29, 2009 at 11:39 PM, Michel Belleville < michel.bellevi...@gmail.com> wrote: > Even better : > $('a.filter').click(function() { > > $(this).closest('ul').children().removeClass('active').end().end().closest('li').addClass('active'); > }); > > Michel Belleville > > > 2009/11/29 Mauricio (Maujor) Samy Silva > > Try this: >> >> $('a.filter').click(function(){ >> $(this).parent().siblings('li').removeClass('active'); >> $(this).parent('li').addClass('active'); >> }); >> >> Maurício >> >> -Mensagem Original- >> *De:* Charlie >> *Para:* jquery-en@googlegroups.com >> *Enviada em:* domingo, 29 de novembro de 2009 03:56 >> *Assunto:* Re: [jQuery] Selector Help >> ... >> >> Dave Maharaj :: WidePixels.com wrote: >> How would I go about adding class to the li in this set up? >> all >> some >> none >> >> ... >> >> >> >> >
RE: [jQuery] Selector Help
Good, practical formatting for understand the chain From: Michael Geary [mailto:m...@mg.to] Sent: Monday, November 30, 2009 3:28 AM To: jquery-en@googlegroups.com Subject: Re: [jQuery] Selector Help That's a nice solution. Let's make it easier to follow with some indentation: $('a.filter').click(function() { $(this) .closest('ul') .children() .removeClass('active') .end() .end() .closest('li') .addClass('active'); }); The basic indentation rules we're following here are: * Put each method call on a line by itself, with the "." at the beginning of the line. (You can put more than one call on the same line, but only when they don't change the selection.) * Where a method creates the jQuery object or changes its element selection, indent the next line. * Where .end() is called, un-indent that line. You could even go overboard on readability and add the missing .end() calls at the very end: $('a.filter').click(function() { $(this) .closest('ul') .children() .removeClass('active') .end() .end() .closest('li') .addClass('active') .end() .end(); }); Now this looks a lot like the way we indent blocks in JavaScript and other languages. Each .closest() or .children() call is matched up with its own .end() call - as is the initial $(this) - and the indentation indicates the code affected by each of those calls. It's more customary to omit those trailing.end() calls, but with or without them, the indentation is a great help in visualizing the structure of a complex chain. -Mike On Sun, Nov 29, 2009 at 11:39 PM, Michel Belleville wrote: Even better : $('a.filter').click(function() { $(this).closest('ul').children().removeClass('active').end().end().closest(' li').addClass('active'); }); Michel Belleville 2009/11/29 Mauricio (Maujor) Samy Silva Try this: $('a.filter').click(function(){ $(this).parent().siblings('li').removeClass('active'); $(this).parent('li').addClass('active'); }); Maurício -Mensagem Original- De: Charlie <mailto:charlie...@gmail.com> Para: jquery-en@googlegroups.com Enviada em: domingo, 29 de novembro de 2009 03:56 Assunto: Re: [jQuery] Selector Help ... Dave Maharaj :: WidePixels.com wrote: How would I go about adding class to the li in this set up? all some none ...
[jQuery] jQuery Selector Help
Long time listner, first time caller ... I am struggling with a selctor and am hopeful someone can help me see the forest through the trees. I am using a WordPress plugin which generates the following HTML: 26 * Christmas Break Christmas Break * http://localhost/?p=104"; style=""> Futsal Training Futsal Training Time: 1:30 pm Futsal Training at NetSports I want to strip the asterisk characters ("*") from the HTML. I have been able to tweak a few things but I am struggling with a selctor which would allow me to eliminate the asterisk. Any help or suggestions would be approeciated. I was trying to do this but innerHTML returns undefined and I am not sure why. jQuery('span.even > br').each(function() { html = this.innerHTML ; // Some manipulation goes here jQuery(this).html(html) ; } I am by no means a jQuery guru so I am sure I am missing something obvious. Thanks, Mike
Re: [jQuery] jQuery Selector Help
I would suggest you to wrap the sections within * into a div and select that div. Thanks & Regards, Dhruva Sagar. On Tue, Dec 22, 2009 at 6:29 PM, Mike Walsh wrote: > Long time listner, first time caller ... > > I am struggling with a selctor and am hopeful someone can help me see > the forest through the trees. I am using a WordPress plugin which > generates the following HTML: > > > 26 > > * > > Christmas Break > > Christmas Break > > * > > http://localhost/?p=104"; style=""> > Futsal Training > > Futsal Training > Time: 1:30 > pm > > Futsal Training at NetSports > > > > > > > I want to strip the asterisk characters ("*") from the HTML. I have > been able to tweak a few things but I am struggling with a selctor > which would allow me to eliminate the asterisk. Any help or > suggestions would be approeciated. I was trying to do this but > innerHTML returns undefined and I am not sure why. > > jQuery('span.even > br').each(function() { >html = this.innerHTML ; >// Some manipulation goes here > jQuery(this).html(html) ; > } > > I am by no means a jQuery guru so I am sure I am missing something > obvious. > > Thanks, > > Mike >
[jQuery] Re: jQuery Selector Help
On Dec 22, 8:03 am, Dhruva Sagar wrote: > I would suggest you to wrap the sections within * into a div and select that > div. > > Thanks & Regards, > Dhruva Sagar. > [ ... snipped ... ] Unfortunately I don't have control of the generated content. The content is generated by a WordPress Calendar plugin that I am reluctant to modify which is why I would like to find a way to do this with jQuery. Mike
[jQuery] Re: jQuery Selector Help
Well, you selected BR elements, which are empty elements, so it's no mystery why this.innerHTML returns undefined... Also, DIVs shouldn't appear inside SPANs...
[jQuery] Re: jQuery Selector Help
On Dec 22, 12:09 pm, Charlie Griefer wrote: > 2009/12/22 Šime Vidas > > > Well, you selected BR elements, which are empty elements, so it's no > > mystery why this.innerHTML returns undefined... > > > Also, DIVs shouldn't appear inside SPANs... > > He did state that he's using generated HTML. He has no control over it. > > Mike - this isn't really a jQuery problem per se. You're jQuery selectors > match DOM elements. Not so much the contents of those elements. > > What you can do is search for the containing element (in this case, you can > look for a with a class of "event"), and replace all instances of />* with just the . > > $(document).ready(function() { > var newHTML = $('span.event').html().replace(/()\s*\*/g, '$1'); > $('span.event').html(newHTML); > > }); > > The expression is looking for a (or or ) followed by any > white space (including tabs), followed by an asterisk. It replaces that > pattern with the alone (removing the asterisk). > [ ... snipped ... ] Thanks for pointing me in the right direction. This is what I ended up getting to work: jQuery("span.event", ".calendar-table").each(function(){ var html = this.innerHTML.replace(/()\s*\*/ g, \'$1\'); jQuery(this).html(html) ; }) ; I changed the regular expression slightly to eliminate the .* portion and changed .html() to .innerHTML. I don't know enough jQuery to know why I had to do that but had seen it elsewhere so tried it and it worked. Thanks, Mike
[jQuery] Re: jQuery Selector Help
[ ... snipped ... ] > > ... and after looking at your code (which always helps), I see you're > referencing "this" (as opposed to jQuery's $(this)), which is why html() > wouldn't have worked. > > In that case, sure. It's been said that "this" is more efficient than > creating a jQuery reference to it via $(this). > > So to clarify... this.innerHTML is the functional equivalent of > $(this).html(), but without the "cost" of creating a new jQuery object for > each iteration of your each(). > [ ... snipped ... ] Thanks for the explanation. I went back and cleaned up my code to use jQuery(this).html() instead of this.innerHTML and all is well. Mike
[jQuery] Selector Help - hover and dblclick
In a table like this: Item One Two Three I want to highlight the rows when hovered. I also wan't to set a different background color on the row when double clicked. I have the following jquery code: $(document).ready( function() { $("[EMAIL PROTECTED]'']").hover( function(){ $(this).addClass('hilite'); }, function(){ $(this).removeClass(); }); $("[EMAIL PROTECTED]'']").dblclick(function(){ $(this).removeClass(); $(this).addClass('dblclckd'); }); } ); Note: in the above selectors that is @class= The hover is highlighting the rows. The double-click is changing the row background. The problem is when if I hover over the previously double clicked row. It loses its styling. What I'd like to do is prevent the hover from acting on any row that has been double clicked. I'm trying to do this based on the hovered rows class, but that isn't working. Ultimately, I'd also like to prevent the double clicked row from running code if previously double clicked.
Re: [jQuery] Re: jQuery Selector Help
2009/12/22 Šime Vidas > Well, you selected BR elements, which are empty elements, so it's no > mystery why this.innerHTML returns undefined... > > Also, DIVs shouldn't appear inside SPANs... > He did state that he's using generated HTML. He has no control over it. Mike - this isn't really a jQuery problem per se. You're jQuery selectors match DOM elements. Not so much the contents of those elements. What you can do is search for the containing element (in this case, you can look for a with a class of "event"), and replace all instances of * with just the . $(document).ready(function() { var newHTML = $('span.event').html().replace(/()\s*\*/g, '$1'); $('span.event').html(newHTML); }); The expression is looking for a (or or ) followed by any white space (including tabs), followed by an asterisk. It replaces that pattern with the alone (removing the asterisk). Disclaimer: I'm no regex guru, so if anyone sees a way to clean up that expression, please feel free. -- Charlie Griefer http://charlie.griefer.com/ 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.
Re: [jQuery] Re: jQuery Selector Help
On Tue, Dec 22, 2009 at 10:34 AM, Mike Walsh wrote: > > [ ... snipped ... ] > > Thanks for pointing me in the right direction. This is what I ended > up getting to work: > >jQuery("span.event", ".calendar-table").each(function(){ >var html = this.innerHTML.replace(/()\s*\*/ > g, \'$1\'); >jQuery(this).html(html) ; >}) ; > > I changed the regular expression slightly to eliminate the .* portion > and changed .html() to .innerHTML. I don't know enough jQuery to know > why I had to do that but had seen it elsewhere so tried it and it > worked. > > Thanks, > > Mike > .html() retrieves the innerHTML. Really no functional difference, but for the sake of consistency, since you're leveraging jQuery, I'd prefer to see consistent jQuery code (unless there's a compelling reason not to). And yeah... just a preference. Not saying wrong or right. But I am saying you shouldn't have "-had- to do that" :) Anyway, glad you got it working. That's the important bit :) -- Charlie Griefer http://charlie.griefer.com/ 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.
Re: [jQuery] Re: jQuery Selector Help
On Tue, Dec 22, 2009 at 10:40 AM, Charlie Griefer wrote: > On Tue, Dec 22, 2009 at 10:34 AM, Mike Walsh wrote: > >> >> [ ... snipped ... ] >> >> Thanks for pointing me in the right direction. This is what I ended >> up getting to work: >> >>jQuery("span.event", ".calendar-table").each(function(){ >>var html = this.innerHTML.replace(/()\s*\*/ >> g, \'$1\'); >>jQuery(this).html(html) ; >>}) ; >> >> I changed the regular expression slightly to eliminate the .* portion >> and changed .html() to .innerHTML. I don't know enough jQuery to know >> why I had to do that but had seen it elsewhere so tried it and it >> worked. >> >> Thanks, >> >> Mike >> > > .html() retrieves the innerHTML. > > Really no functional difference, but for the sake of consistency, since > you're leveraging jQuery, I'd prefer to see consistent jQuery code (unless > there's a compelling reason not to). > > And yeah... just a preference. Not saying wrong or right. But I am saying > you shouldn't have "-had- to do that" :) > > Anyway, glad you got it working. That's the important bit :) ... and after looking at your code (which always helps), I see you're referencing "this" (as opposed to jQuery's $(this)), which is why html() wouldn't have worked. In that case, sure. It's been said that "this" is more efficient than creating a jQuery reference to it via $(this). So to clarify... this.innerHTML is the functional equivalent of $(this).html(), but without the "cost" of creating a new jQuery object for each iteration of your each(). -- Charlie Griefer http://charlie.griefer.com/ 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] Selector help for new user please
How would I turn this pseudocode into jquery? if div#sidebar2 contains div.plugin { div#sidebar2 width = 160px div#content margin-right = 170px } I've been at this for a couple hours and I can't figure it out, so any help is really appreciated. Thanks, Doug
[jQuery] Selector help - All inputs except radio buttons?
I currently have this? var params = $('input,select,textarea').serialize(); Is there a simple way to serialize all inputs expect for radio buttons?