jquery-selectors

JQuery select text next to an input checkbox?

Using JQuery, is there a simple way to select the text immediately after a checkbox? <li>bleh..</li> <li> <input type="checkbox" id="cbx1" value="10" />&nbsp;Very important text. </li> <li>bleh..</li> I want to use jquery to select that "Very important text." minus &nbsp; ...

Can't limit "return false" to parent element only; want children to return true!

Hey everybody - This is my first time here so I hope I don't come off too stupid! I have a very simple jQuery problem: I have a database-generated ul-based navigation and I want list items that contain other lists to toggle showing those contained lists. The (generated) lists look like this (Wordpress code; ignore the Japanese): <div ...

Get value of multiselect box using jquery or javascript

In the code below, how to get the values of multiselect box in function val() using jquery or javascript. <script> function val() { //Get values of mutliselect drop down box } $(document).ready(function() { var flag=0; $('#emp').change(function() { var sub=$("OPTION:selected", this).val() if(flag == 1) $('#new_...

Showing right sub-ul of parent ul menu

Hello, i have this html menu: <ul id='main'> <li class='active current' id='lighty'> <a href='/'>Lighty</a> <ul> <li class='sub'> <a href='/'>Hem</a> </li> </ul> </li> <li id='community'> <a href='/community'>Community</a> ...

How to serialize as an array of objects from multiple fields in jQuery?

Hi, I'm using jQuery to dynamically add new divs containing a few fields. I'm adding new tunes in this example of output: <div id="uploadedTunes"> <div class="tune"> Title:<input type="text" name="Title"> Length:<input type="text" name="Length"> </div> <div class="tune"> Title:<input type="text" name="Title"> ...

Odd jQuery selector used in a find method

Does anyone have any idea what this jQuery selector will do? object.find('td:eq(1) div div'); I know that the td:eq(1) will get the 2nd td element in the object, but what will the 2 div's referenced at the end of the selector do? ...

jQuery: select all elements of a given class, except for a particular Id

This is probably pretty simple. I want to select all elements of a given class "thisClass", except where the id is of a given id "thisId". i.e. something equivalent to (where -/minus implies remove): $(".thisClass"-"#thisId").doAction(); ...

Quick help with some jQuery toggle

I have the following code: <script> $(document).ready(function() { $('.toggle_section').click(function(e){ parent = $(e.target).closest("div") objChild = parent.children('div'); $('.sectionContentId').hide(400); $(objChild).toggle(400); }); }); </script> <br /> <d...

jQuery detect visible but hidden elements

This seems like it should be fairly easy - but I can't find the right selector for it According to the docs (http://api.jquery.com/hidden-selector/ and http://api.jquery.com/visible-selector/)... Elements can be considered hidden for several reasons: An ancestor element is hidden, so the element is not shown on the page. What I want ...

jQuery select image in div if image parent does't have a certain class.

Wordpress wraps images with captions in a div with a class of .wp-caption. I'm looking for a way to select images that don't have this div so I can wrap them in different div. (to keep a consistent border around all the images) <div class="blog-post-content"> <div id="attachment_220" class="wp-caption alignleft" style="width: 310px">...

Faster jquery selector for finding a number of TD elements

I have a table where each row has 13 TD elements. I want to show and hide the first 10 of them when I toggle a link. These 10 TD elements all have an IDs with the prefix "foo" and a two digit number for its position (e.g., "foo01"). What's the fastest way to select them across the entire table? $("td:nth-child(-n+10)") or $("td[id^=...

need help with jquery selectors

I've got code like that: <ul class="gallery_demo_unstyled"> <li class="active"><img src='001.jpg' /></li> <li><img src='002.jpg' /></li> <li><img src='003.jpg' /></li> <li><img src='004.jpg' /></li> <li><img src='005.jpg' /></li> <li><img src='006.jpg' /></li> </ul> <div class="Paginator"> <a href="....

Binding KeyUp event to Input Field

I am dynamically generating textboxes in ruby using <%0.upto(4) do |i| %> <%= text_field_tag('relative_factor[]', @prefill_values[:relative_factor][i],:size => 6,:maxlength => 5) %> <%end%> it generates following HTML markup Another set of textboxes: <%0.upto(4) do |i| %> <%= text_field_tag('rating_factor[]', @prefill_va...

jQuery - How to remove a DOM element BEFORE complete page load

Now this may seem like a silly question, but I need to know how to remove a DOM element BEFORE it is displayed to the user. In short, I am using a div that has a background image alerting the user to enable javascript before proceeding. If the user has javascript enabled I am using jQuery to remove the DOM element, in this case $(".check...

edge case for selecting a checked radio input with jquery

Hi all! I have a problem selecting a checked radio button with jquery. The radio buttons are generated by a function from a MVC that i'd rather not change and its name is like id[number]. Simply put, I have to check if any of these buttons are checked: <input type="radio" name="id[1]" value="1"/> <input type="radio" name="id[1]" value...

jquery modal popup read from a file

For the below code, there ia a form in the location /home/form.php .How can this form be opened with the below code.i.e, the modal dialog $dialog.html(data) .dialog({ autoOpen: true, position: ['right','bottom'] , title: 'Emp Form', draggable: false, width : 300, height...

jquery - How do I get the attribute of the root, or top most < li > if I'm nested deeply down in an unordered list...

I want walk back up the tree menu of a nested unordered list to the top most < li > and retrieve the "p_node" attribute using the toggle function of jquery. So, for example, when I click on "Annie" I want to retrieve the root li, which in her case is "mCat1" and extract the value for "p_node" to be used in the script. How can I accompli...

How can one select specific sibling of a context node using jQuery?

How can one select a specific sibling of a context node using jQuery? Specifically, given context node myContextNode select the sibling span with class myClass. document.evaluate("../span[@class='myClass']", myContextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null). singleNodeValue; ...

How do I change an attribute in an HTML table's cell if I know the row and column index of the cell?

I know nothing about jQuery but am an experienced C++ programmer (not sure if that helps or hurts). I found jQuery code that gives me the row and column index of a cell in an HTML table when a user clicks on that cell. Using such row-column index numbers, I need to change an attribute's value in the previously selected cell and in the ce...

jquery textarea validation

How to check for null,white spaces and new lines while validating for a textarea using jquery. If the textarea is empty and has only new lines or spaces should raise an alert ...