jquery-selectors

Using regex to change sub element image from off to on and back

In an effort to keep code down I was hoping to use regular expressions with jQuery to switch the on and off states inside a hover for an image. jQuery: $(function(){ $("ul.dropdown li").hover(function(){ $(this).addClass("hover"); $('ul:first',this).css('visibility', 'visible'); }, function(){ $(this).removeClass("hove...

jQuery - How do you select children of children when in the context of 'this'?

On rolling over a wrapper div, I need different nested children to do different things. One div needs to fade to one level of opacity, another div needs to do another thing. It's all wrapped in quite a lot of stuff that i can't tamper with. I have NO idea how to call children in children.... I have tried every frikkin combo of jQuery...

Remove parent of a parent with jQuery and DOM

My html looks like this : <li> <div> <p class="delete"> <a href="#">X</a> </p> </div> <div class="friend-avatar"> <img src="" /> </div> </li> After clicking anchor tag in 'delete' paragraph I'm showing a popup (using jquery-alert) and if user selects 'Yes' I would like the whole li c...

What jQuery selector can I use to match these HTML elements (requires ":contains()")?

I'm trying to find a jQuery selector that will match only the element that directly contains the text "PDT" in the following two examples (truncated for brevity): <div> <p> <strong>(07-27) 21:28 PDT SAN FRANCISCO</strong> -- San Francisco supervisors ended more than a decade... </p> <p>The 10-1 vote, with only Supervisor C...

Best alternative to dynamically highlight my Navbar link using jQuery?

Hey, I have an ASP.NET website, on the masterpage I have a basic navigation menu: <ul id="menu"> <li><a href="Default.aspx"><span>Home</span></a></li> <li><a href="Services.aspx"><span>Services</span></a></li> <li><a href="HowItWorks.aspx"><span>How It Works</span></a></li> <li><a href="ContactUs....

jQuery Selector Question

EDIT: As the below solutions have not worked, I've included more code to be clear. I am dynamically generating the following html. It basically is a span that's positioned so that whenever productControl is clicked the productMenuHolder div pops up with a menu. Upon mouseleave, the menu disappears. <span class="productControl"> <di...

jQuery: Selector inconsistencies, can someone please explain what i'm doing wrong here

Why does this work: $("div.cat_rollout").mouseover(function(){ $(this ).removeClass().addClass("cat_rollover"); $(this).animate({ fontSize: "22px" }, 'fast' ); }).mouseout(function(){ $(this).removeClass().addClass("cat_rollout"); $(this).animate({ fontSize: "10px" }, 'fast' ); }); But this does not: $('.vp...

jQuery: Detect if element exists

In my code I have the following html that gets appended to a List Item when the user clicks on a specific element. <span class="greenCheckMark"></span> Using jQuery, how would I detect if the element existed, and if so, not add another green checkmark? $('.clickedElement').live('click',function(){ //does the green check mark exist? i...

Multiple selectors or multiple functions - any efficiency gains?

Hi all, I'm wondering if its possible to make the following code more concise: $('#americasTrigger').hover( function () { $('#americasImg').fadeIn() }, function(){ $('#americasImg').fadeOut() } ); $('#europeTrigger').hover( function () { $('#europeImg').fadeIn(); }, function(){ $('#e...

jQuery how to specify an existing selector

How do I do a selection on a existing selection in jQuery? This is the given HTML <div id='search'> <form action='' method='GET'> <input id="searchbutton" type='submit' name='qs' value='search'> <div id="searchoptions"> <input type="checkbox" checked="checked" id="search_books book" name="search_b...

jquery: select all elements after nth

Hi, I have x number of <div> and I need to select all after n. <div class=foo>4:00</div> <div class=foo>5:00</div> <div class=foo>6:00</div> <div class=foo>7:00</div> <div class=foo>8:00</div> For example, given n=3 and div.foo, remove all div.foo after the 3rd div.foo would yield: <div class=foo>4:00</div> <div class=foo>5:00</div...

How can I uncheck disabled radio buttons using jQuery?

Here is some code that checks if a radio button is disabled. How do I reform this to make the radio unchecked if it is currently disabled? And yes I still want to remove the parent CSS class. Thanks. $('input:disabled', true).parent().removeClass("style1"); Why won't this work? $('input:disabled', true).attr('checked', false).parent(...

Jquery dynamic selector on Click

Hi all, I need "i" click functions depending on variable unknown length: for(i=0;i<=unknownLength;i++) {$("#group_link_"+i).click(function() {//asynchronous call to a Web Service for the specific content on group_link_i div, here I will use $("#group_link_"+i).val()} );} This code is not working. However, the same code, if i delete ...

How can I select the input child of an adjacent row using jQuery?

I'm hoping someone can help me with the syntax for a jQuery selector. I just can't get it to work! I'm trying to select the input field that relates to the table row that contains a div with class span. Here's the HTML: <tbody> <tr><th scope="col"><label for="username">Username</label><br /><?php echo form_error('username');?></th></t...

JQuery Selector problem with prevAll

Hi, I'm having trouble getting some Jquery code to work. I think my problem is stems around how I'm writing the selector. Here's my original HTML: <div class="rotate"> <div class="offer-holder"><span class="lblSeconds">7</span></div> <div class="offer-holder"><span class="lblSeconds">3</span></div></div> ...and here's my Jqu...

:visible selector not working in Internet Explorer

I'm working on some basic form validation styles for an ASP.Net website. I need to select all span elements that are visible, and add a css style to another element. (Just to indicate which input fields are invalid.) The below code works like a charm in FF and Safari, but fails in IE. I've narrowed the problem down to the :visible selec...

How do I find all elements with a specific 'name' attribute using jQuery

I want to find all the elements on my page that have a 'name' attribute containing 'x' or 'y' and add a certain class to those elements. So, the logic I'm looking to apply is If anything has 'x' or 'y' in the name attribute then add .yepItHasXorY It seems like a simple thing. I understand how to search based on an ID or Class but not...

jQuery custom Accordion - not working in IE/ Safari / Chrome

My script should expand/collapse UL elements when a corresponding is clicked. It works in FF fine and can be viewed over here. I am loading jQuery lib first then my own examples.js which contains: function initExamples() { $('#examples ul').hide(); $('#examples ul:first').show(); $('#examples li a:first').addClass('exampleon'); ...

JQuery basic selector usage and non unique element ID

I'am maintaining a GUI built using JQuery. In one part of the GUI, multiple tabs can be opened to edit data. When a new tab is opened, it is created by cloning the first tab content div and updating the input fields in the div. The new tab is given a unique ID based on the tab index, but all other ID's within the cloned tab div are the...

CSS3/jQuery selector to style group of 2 rows via the :nt-child() selector

I have a <table> that the data is separated per 2 <tr>'s So i want to style the rows(each 2 rows) as zebra stripped, but each set of 2 should be styled. I am trying something like: tr:nth-child(3n+1), tr:nth-child(4n+1){background:#f7f7f7;} I would prefer a CSS3 solution, but if only jQuery can do it, that will be fine. Please see...