jquery-selectors

JQuery selector logic fails if id has '.' in the value. Any solution ?

Hi, I am using Spring Forms for my web application. For nested properties, the form tag generates the input elements having id / name in form of . For example, Person is the command class and Address is contained into its address field then the city element would be, <input type="text" id="address**.**city" name="address**.**city" /> ...

Selecting elements with a certain background color

I want to select a bunch of spans in a div whose CSS contains a particular background color. How do I achieve this? ...

jQuery child of clicked element

Hi, I've got a list of links which have a click event attached to them, I need to get the ID from the child A link. So in the example below if I clicked the first list element I'd need google retuned. I've tried '$this a' but can't quite work out the syntax. jQuery: $("ul li").click(function(event){ $("input").val($(this).html()); ...

jQuery How do I get the div in this code?

Hi, How do I get the div from within this (the last) list item? Currently I have this, which is just plain ugly...any suggestions on a cleaner selector/ solution? var div = ul.append("<li><div></div></li>").contents("li:last-child")[0].children[0]; Thanks! ...

jQuery delete all table rows except first

Using jQuery, how do I delete all rows in a table except the first? This is my first attempt at using index selectors. If I understand the examples correctly, the following should work: $(some table selector).remove("tr:gt(0)"); which I would read as "Wrap some table in a jQuery object, then remove all 'tr' elements (rows) where the...

How do I get a jQuery selector's expression as text?

I have a jQuery selector, which has a chained function. Inside the function I want to get access to the TEXT representing the expression for the selector. $("cat dog").function() { // how do I get access to the "cat dog" string from inside THIS function ? }; I've over simplified in this code sample what I actually want to do. I'...

jQuery - how to select a tr that contains th's?

Title pretty much says it all. Given a table like <table> <tr> <th>Header 1</td> <th>Header 2</td> </tr> <tr> <td>Datum 1</td> <td> Datum 2</td> </tr> <tr> <td>Datum 1</td> <td> Datum 2</td> </tr> </table> How to select the row which contains the th headers and no other? ...

problems with a jquery selector

Here is my view source: <input id="ctl00_cp_ctrlNew_lendeeMe" type="radio" name="ctl00$cp$ctrlNew$whoBorrowed" value="lendeeMe" /> And I am trying to use this selector to check one of them, but it is not working: $("input[@id$='lendeeMe']").attr('checked','checked'); but if I do this, it works fine: $("#ctl00_cp_ctrlNew_lendeeMe")...

How can I get which radio is selected via jQuery?

I have two radio buttons and want to post the value of the selected one, how can I get the value with jQuery? I can get all of them like this: $("form :radio") But how do I know which one is selected? ...

jQuery and ASP.NET names

What is the correct way to get a control that was rendered by ASP.NET with jQuery? Example: I have a checkbox that was generated like this: <input id="ctl00_Content_chkOk" type="checkbox" name="ctl00$Content$chkOk" /> If I want to select it to get if it's checked, I tried this: $('form input[name=chkOk]').attr("checked") and $('c...

jQuery Selector: Id Ends With?

Is there a selector that I can query for elements with an ID that ends with a given string? Say I have a element with an id of "ctl00$ContentBody$txtTitle". How can I get this by passing just "txtTitle"? ...

JQuery "long >"

How to query child containers, and not inside containers (thats not about attributes) <div class="container"> <div> <div class="container" child> <div> <div class="container" inside> <div> <div class="container" child> <div> <div class="container" inside> </div> Edit:...

How to select and replace the whole page with jQuery

My design of a page forces me to refresh the whole page with html that I have loaded via ajax. $('html').replaceWith(data); Gives me errors. Any ideas? ...

jQuery: How to select "from here until the next H2"?

I'm setting up a very straightforward FAQ page with jQuery. Like so: <h2>What happens when you click on this question?</h2> <p>This answer will appear!</p> This is all inside a very specific div, so I'll be selecting the header with $('#faq h2'). Simple, right? Click on the H2, and use this.next() to make the next paragraph show up...

jQuery advanced selector

Can I use comparison statements within a jQuery selector method? eg. I have a list of divs generated by php that all use the same CSS class but have value attributes of 1, 2, 3 etc. I also have a text input field with an id. This field can accept numbers only. I would like to select the div (from the long list) that has a value attribute...

Jquery: Selecting images with a specific source?

I've looked high and low through the docs and internet, and damn if I can't figure this out. I would like to use jquery to select all images with a specific source and apply a tool tip to them. I have the tooltip working fine when I'm finding the target with classes, but I figured it would be a bit more efficient and avoid adding unnee...

What JQuery selector excludes items with a parent that matches a given selector?

I have var $set = $('.foo,.bar').filter( function() {return $(this).parents('.baz').length < 1;}); as a way to select all the elements whose classes are either foo or bar and who do not descend from an element whose class is baz. Is there a selector that will accomplish the same thing without the need for a filtering lambda? <di...

Selecting child div by id knowing a parent div id with JQuery selectors

I have this html: <div id="top"> <div id="potato"></div> </div> <div id="bottom"> <div id="potato"></div> </div> I am trying to use JQuery to access the bottom potato div, and none of the following work. $('#top #potato').html('Russet'); $('#bottom #potato').html('Red'); $('#top > #potato').html('Russet'); $('#bottom > #potato').htm...

Working with jQuery selectors - ScrollTo

I am working with the jQuery ScrolTO plugin: http://demos.flesler.com/jquery/scrollTo/ at this site: www.imfrom.me I have the arrows to navigate up and down and as of now I am using: $('.down_stream').click(function(){ $.scrollTo( '#stream', 1500, {easing:'easeOutElastic'} ); }); So on click of .down_stream go to #stream, aka t...

jquery - further querying "this"

i want to further use css selectors on "this" how can i do it? specifically i am trying to select this's sibiling ul > li > a's how can i do it? this + ul > li > a i find that using sibling i cannot do .sibling("ul > li > a"), but i can use 3 .siblings() to do it? maybe i am using the wrong function? maybe i shld use find()? but th...