jquery-selectors

jquery find versus context selection

Having the following html snippet <div class="something"> <p>Some text</p> </div> <div class="somethingElse"> <p>some other text</p> </div> I think the following jquery snippets are identical (will have the same result): $(".something").find("p").css("border", "1px solid red"); $("p", ".something").css("border", "1px solid r...

jQuery: What does $("html") mean?

What does $("html") mean? i.e. $("html").scrollTop(0); ...

Select and disable each input field within a form, wrapped in a table in jquery

Hi, I am disabling a form based on a checkbox... I am having trouble adding the disabled attribute. here is what I got so far: HTML: <table id="shipInfoTable"> <tr> <td>Name:</td> <td><input type="text" name="name" /></td> </tr> ... </table> Javascript selector/attribute manipulation(jquery): $("#shipInfoTable tbody tr...

jQuery - checking existence of elements

Ok so basically I need to check,whether in my menu #Container exist any third level elements (h3 to be exact) and if yes give them some attribute. If not give this attribute to second level element (h2) which always exists. Is : if ($('h3')) { //some attribute } else { //some attribute }; the right method ? ...

jQuery $(element).each function doesn't work on newly added elements

Hi there, I am using .each function to iterate trough list of elements. I am having initial list of matched elements and .each works great on these. But I can add new elements via AJAX method... .each don't work on this newly added elements? I know about live events and rebinding of events for newly added elements, but .each is not ev...

Save a reference to a particular selector

Ok, what I am after is quite simple. I have click handler for multiple radio group sets. Inside the handler I am passing some parameters to a functions parameters references are relative to the group set but their path are the same. So I basically have: $(document).ready(function(){ $("input[name='radioGroup1']").click(function(){ ...

jQuery selector - what is faster?

Hi, $('#content td#foo').show(); $('td#foo').show(); The td is somewhere deep in the content div. What is faster? ...

JQuery can't call function on HTML placed using .load

Hi, I have come into a bit of a problem. I am dynamically updating dropdown lists using JQuery and PHP. I am using the following JQuery code to run a PHP page and insert the results into the page: $("#booking-form-area").change(function() { ajax_availabletimes(); }) function ajax_availabletimes(){ var venue_val=$("#booking-form...

jQuery selector returns duplicate elements in Safari

I have a jQuery selector that queries elements by tag name and class. In a query that I'd expect to return three elements, Safari (v3.1.1 for Windows) returns an extra element. The cause seems to be the numeric ID*. Changing the ID to a non-numeric eliminates the duplicate element. Strangely, changing the ID of the first element to...

[jQuery] selection on condition

I'm trying and trying and can't make it working. I have a ul class="first" . From all the ul's "first" in the template I need to select only those containing ul class="second" and for the selected change h2 href to "#". Problem is that when I find this specific "first" with "second" I can change "second" parameters with no problems but i...

jQuery: selecting grandparents

is there a better way to select grandparents elements in jquery in order to avoid this ? $(this).parent().parent().parent().parent().parent().children(".title, .meta").fadeIn("fast"); thanks ...

problem with finding select element which id attribute Starts With

a want that, he found all select elements with id than begins with 'chbTypes' and write something like that $("input[id^='chbTypes']").change(function() { //some operations }); but it's not works. some idea, please. ...

Limiting characters to a fixed size in javascript

In the below code var panel= '<div id="title" style="display:inline;font-size:150%;color:white;background:transparent;text-transform: none;width:150px;"> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div> <div name="images" id="name" style="display:inline;position: absolute; margin-left: auto;margin-right:auto;left: 0;right: 0;width:350px;hei...

Formfill in Javascript not working?

var tagMatch; if (tagMatch = window.location.href.match(/\/questions\/ask\?tags=([^&]+)/)) { $(function() { if (!$('#tagnames').val().length) { $('#tagnames').val(unescape(match[1].replace(/\+/g, ' ')); } }); } Hi all, this JS code is supposed to match the latter-part of a URL of the fo...

CSS selector for innermost TABLEs?

Is there any way to select only innermost tables? That is ones that do not contain any more tables inside them? I know I can filter by element.getElementsByTagName("table").length == 0, I'm just wondering if there's a more elegant solution. ...

jQuery selector

I have this HTML code: <div class='com_box'> <div class='com_box_c'> <div class='com_box_info'> <a id='quote'>quote</a> </div> </div> </div> When I click in a#quote i want to add a textarea after '.com_box'. How do I select the outer div? Here is my no working try so far: $('a#quote').click( function() { var...

jQuery/Sizzle selector to find current element's parent?

Is there a way I can get the selected element's parent using only jQuery's/sizzle's CSS selectors? I need to be able to get an element's parent while using jQuery, but I'm unable use jQuery('#myelement').parent() since I'm receiving the selector as a string and the "user" needs to be able to move back up the tree. I can't see anything ...

Get all Select Elements in a Form by referencing $(this) instead of $("form select")

Hi Guys I'm currently getting all the Select elements that exist in a form with the following: $("form").submit(function(event) { // gather data var data = GetSelectData($("form select")); // do submit $.post($(this).attr("action"), data, ..etc) }); Instead of passing in $("form select"), is there a way I can say som...

jQuery selectors: logical OR

I can't seem to see the forest for the trees right now (Looked at the api docs already). It has to do with jQuery selectors: What I'm trying to do is to select all elements that have class subtitle or headsection. Something like this: $('.headsection || .subtitle'); To be more specific: I want to use this selector with the function next...

jquery selecting all elements except the last per group

I have a table that looks like: <table> <tr> <td>one</td><td>two</td><td>three</td><td>last</td> </tr> <tr> <td>blue</td><td>red</td><td>green</td><td>last</td> </tr> <tr> <td>Monday</td><td>Tuesday</td><td>Wednesday</td><td>last</td> </tr> </table> What I want is a jquery selector that will choose ...