jquery-selectors

jQuery, selecting form elements by name, getting: Error: uncaught exception: Syntax error, unrecognized expression: [@name="reset"]

I'm trying to select an select element by name I found this thread showing how to do it, and I followed it but I'm getting Syntax error. I'm using jquery 1.4.1, here's my code. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&g...

jquery syntax function(){mylongfunc();} vs. just mylongfunc();

why do I have to do this: $('#myfoo').change(function(){mylongfunc();}); instead of this: $('#myfoo').change(mylongfunc()); what does that extra function(){} wrapper do? ...

how to parse jquery ajax xhtml response?

Sorry if this has been posted many times. But I've tried many variations and it still doesn't work. The HTML comes back from the jquery AJAX call fine and I am trying to remove the header and footers from the response using: // none of these work for me $("#content", data); $("#content", $(data)); $(data).find("#content").html() I'v...

JQuery: show div on radiobutton select

Hi, I am trying to use JQuery to show a div when the user selects a particular radio button (Other) within a radiobutton group. The html is below <div id="countries"> <input id="Washington_D.C" TYPE="RADIO" NAME="location" VALUE="Washington">Washington D.C</input> <input id="Other" TYPE="RADIO" NAME="location" VALUE="">Other</input> ...

JQuery: Selector that contains some text, but doesn't contain others

Sorry if this question is mind numbingly easy to answer, but I'm a bit new to JQuery and I have a tight deadline. I am looking for a selector for textbox elements that have this format: id = "FixedName_#" "FixedName" will always be "FixedName", but I only want to find elements where the # is positive. So I would want to find "FixedNa...

JQuery: How to select all elements except input and textarea? (to disable keydown event)

I am trying to disable the backspace key in my jQuery app, so that it does not cause the browser to go back a page. However, I do not want to disable it if an input or textarea element is focused, because I want backspace to work properly there. So, I want to select anything that is not an input or textarea. Here is the code. The prob...

Jquery: Handling Checkbox Click Event with JQuery

I can't figure out what is going on here. I have some nested lists of checkboxes that I would like to check when the parent is checked. More importantly, I can't even get the alert to show up. It's as if the click event is not firing. Any ideas? <script type="text/javascript"> $(document).ready(function() { $("#part_mapper_list inp...

jquery: why a selector returns me an array, but attribute doesnt?

Hi. I'm trying to understand JQ better. I'm calling an JQ object $(".FamiliesList li li span[class!='']").prev().find('option:selected') this returns back to me an array of all the options that their span parent's brother has a classname. [option, option] Now- I want to return back an array of the option's values $(".FamiliesLis...

jQuery - Add click event to Div and go to first link found

Hi guys, I think I've been too much time looking at this function and just got stuck trying to figure out the nice clean way to do it. It's a jQuery function that adds a click event to any div that has a click CSS class. When that div.click is clicked it redirects the user to the first link found in it. function clickabledivs() { ...

What is the Relative Performance of Pseudo-Class and Custom Selectors?

It's my understanding that, in terms of selector speed, that #ID selectors are fastest, followed by element selectors, and then .class selectors. I have always assumed that pseudo-class selectors and custom selectors (those in the form ':selector') are similar to .class selectors, but I realised that I'm just not sure. I realise that t...

Expanding / grow a JQuery element selection?

In the Jquery example below, I would like to expand $(this) before it is cloned, so it includes everything contained in the parent class "comment". How do I do this? I've tried using ReplaceWith($(this).parent('.comment').clone()... and it does not work! $(document).ready( function(){ $('.forumthreadtitle').siblings().hide(); $('.fo...

Cloning a selector + all its children in jQuery?

I'm having trouble getting the following JQuery script to function properly - its functionality is as follows: 1) Hide the content below each headline 2) Upon clicking a headline, substitute the "#first-post" with the headline + the hidden content below the headline. I can only seem to get the script to clone the headline itself to #f...

Traversing from Bookmark Hashtags (#bookmark) in jQuery?

I am having trouble traversing from a bookmark has tag in jquery. Specifically, the following HTML: <a id="comment-1"></a> <div class="comment"> <h2 class="title"><a href="#comment-1">1st Post</a></h2> <div class="content"> <p>this is 1st reply to the original post</p> </div> <div class="test">1st post second line</div> ...

jQuery check if element has a class begining with some string

I need to loop through some elements in the page and then, for each one, if it had a class beginning with, for example, "C", do something. $('#dialog li').each(function(){ if ($(this).hasClass("^C")){ //do something } } It may sound silly, but what selector/method should I use on the if clause? Thanks in advance. ...

jQuery selector depending on children

Hi guys, I have an HTML form consisting of some text-inputs. I'm using jqTransform to prettify them. Now I want to add two buttons that will add and remove text-input dynamically. Adding is easy: $('#container').append(''); $('input[name=foo]:last-child').jqTransInputText(); But removing is tricky: $('WHAT-TO-SELECT').remove(); ...

Use jQuery to find div by background color

I'm trying to use jQuery to find the number of divs that are both visible, and have a background color of Green. (Normally I'd just add a class to the div, style it green, and check for that class in jQuery but in this instance, I can't actually change the markup of the page itself in any way) I currently have the visible div part work...

Iterating changes using jQuery?

In the HTML below, I would like to copy the "submittedby" beside "message", within the H2 tag: <div class="comment"> <H2 class="threadtitle">Message 1</h2> <span class="submittedby">James</a> </div> <div class="comment"> <H2 class="threadtitle">Message 2</h2> <span class="submittedby">Bill</a> </div> <div class="comment"> <H2 class="t...

jquery select element inside a class

Hi fellow programmer I want to select an anchor inside a div like this <div class="response content"> Disapproved Bank Mandiri<br><br> <p> <a class="showlist" href="#">Back to list?</a> </p> </div> What is the jquery to do this ? ...

Best way to change the content of 2 divs at once using jquery roundabout?

Hi all, I'm using jQuery roundabout to build an animated logo on my site - I want content to change when I click on each item, something like this: http://fredhq.com/projects/roundabout/demo/images/ I have already implemented the JS on that page, which is working fine, but I was wondering what would be the best way to also make anothe...

Highlighting text beween custom tags

In a xhtml, i want to highlight the text between two self closing tags s1 and s2 whose attribute "ind" has the same value. Eg. <s1 ind="1"/> and <s2 ind="1" /> Eg. <html> <body> <a> <b>Some <s1 ind="1"/> text></b> <c>data <s2 ind="1"/>here</c> </a> </body> </html> I want "text data" to get highlighted. Is is possible to achi...