jquery-selectors

jQuery selector syntax question

Here is my html: <form> <dl> <dt>&nbsp;</dt> <dd><input type="hidden"></dd> <dt>Dont hide this one</dt> <dd><input type="text"></dd> </dl> </form> I'm using jQuery to hide the dt/dd elements where the input type is hidden with this code: $("input[type=hidden]").each(function() { $(this).pa...

jquery newbie: how to efficiently do multiple actions on same DOM element?

Hi everyone, I recently learned (here on stackoverflow : ) ) that when using jquery every time I write $("...") a DOM search is performed to locate matching elements. My question is very simple: how do I efficiently perform a series of actions (using the nice methods of jquery objects) on a DOM element I have located with jquery? Cur...

Selector and Iterating Through a Table Within a Div

I have been working on this and cannot get this iterator to work. I have the following HTML and am trying to iterate through all rows (except the first row) and extract the values in cells (td) 2 and 3 : <div id="statsId"> <table width="220" cellspacing="0" cellpadding="0" border="0"> <tbody> <tr> <td widt...

JQuery: accessing LI nodes?

I have the following HTML <ul id="listing"> <li>...</li> <li>...</li> <li>...</li> </ul> How can I access the 2nd LI inner text? Can I do $("#listing li").[1].text() If not, what is the sytax? ...

How to select one of a group of element using Jquery?

<img style="cursor: pointer" src="../common/images/plus.jpg"/> View History($revisions) How to select the image button above? I want to select image with a source of ../common/images/plus.jpg and of course the image must be clickable. I added <script> $("img[src=../common/images/plus.jpg]").click(function(){ alert("ok"); }...

How to get html string of a child tag and parent tag using jquery?

For example if I have HTML ul list like <ul id="ulIdentificator"> <li id="li0"></li> <li id="li1"></li> <li id="li2"><label id="label1"></label></li> </ul> If I use jQuery like this var htmlStr = $("#li2").html(); The result will be only string that contains label tag <LABEL id="label1"></LABEL></li> I need to get ...

Jquery selector question: referencing a specific element without knowing the ID

Is there a way to reference a control via a Jquery selector without knowing an ID? I was envisioning a function called on mouseover. I've been looking through the documentation but I haven't found anything yet and have the vague sense I'm missing something easy. Update: Zombat, that seems reasonable but I have a problem here that app...

Syntax for Multiple Selectors in jQuery when using OR

I'd like to execute some javascript if button 1 is pressed OR button 2 is pressed. I'm using the notation pasted below, (The code below does not work but I've supplied it to illustrate what I am trying to do). I know I can wrap up the code to execute into another function, and then write two blocks of code (1 for each button) but I'd j...

Using Jquery to add/remove a class based on body Id

I'm no javascript master, but I need to create a script that accomploshies the following. If body id="index" add class"current-selected" to anchor tag where href=index.php If body id="services" add class="current-selected" to to anchor tag where href=services.php etc. Does this make any sense? Can anyone help? Thanks if you can! Abb...

Passing divs information

I have a series of divs that have similar ids with the exception of a unique # at the end (cartbtn0, cartbtn1, etc.). I have created one generic function that will work across all the divs using a wildcard, but I need to be able to capture the unique # of the div that was clicked in order to replace the 0 in #cartbox0:hidden. Can anyone ...

why is jquery select load looping

I can't figure out why this is alerting me several times for each change... $(function(){ $("#shift_name_<?php print $shift_id;?>").change(function () { $(".alertmessage").load("messages.php?eid="+$("#shift_name_<?php print $shift_id;?>").val(), function(data<?php print $shift_id;?>) { if(data<?php print $shi...

jQuery sum values from items above

I have small problem. What I want to achieve is adding sum of values from above elements to each one. For example every position have got it own time value hidden in attribute. I can get it by using jQuery var time = $(ui.draggable).attr("time"); now we got 4 positions with time as follows: 432 sec 123 sec 5634 sec 654 sec Now I ...

jQuery - selector problems in hiding tab content

I'm having trouble hiding the contents of some divs in a pseudo-tab set up - my code is at http://rudderlive.bito.org.nz/employment%5Fdev2.asp Tab 1 to Tab 2 works fine, but moving from Tab 2 to Tab 3 does not hide the div of Tab 2, and moving from Tab 3 back to Tab 1 doesn't hide the Tab 2 or 3 divs. My code is as follows - but it mak...

Jquery not selector problem

First of all thank you for your consideration. I have an html document with a wrapper (container) inside. I want to make it so that when somebody clicks on the body section of the page, they are redirected to xxx, but if they click on the wrapper (the content of the page) they don't get redirected. I have tried everything but the jquery...

jQuery: select an element's class and id at the same time?

I've got some links that I want to select class and id at the same time. This is because I've got 2 different behaviours. When a class of links got one class name they behave in one way, when the same clas of links got another class name they behave differently. The class names are switch with jquery. So I have to be able to select a l...

Selecting a column (jQuery)

$('.table tbody td:eq(3)').addClass('col4'); ..works, but only selects the first cell, not all cells in the column. ...

dynamically add html element using jquery

hi , based on the answer to my previous question by BlausC i am now able to use jquery to a certain extent. but now i need to add a checkbox control to the table created by jquery based on a postback from servlet. the code i am using is $("#linkInstr").click(function(){ var arr=new Array(); var cdid=$("#cboinstr option:selected")...

Getting a range of elements in one jQuery selector

My problem is that I have a table, but I only want a subset of the rows, from first index to last index. I thought you could do it like this: $('table tr:gt(2):lt(5)'); I thought it would give you only rows #3 and #4 but it ends up giving you more than that. How can I tell the selector to choose only rows #3 and #4? ...

jQuery (Append)

For instance I have this html code <div class="messageContainer"> <div class="message"> </div> </div> ---Here <div class="messageContainer"> <div class="message"> </div> <here> :) </div> Now I need to create a div with some information located in the text ("---Here"). Is there any way how obviously by using jQuery. ...

Replace all (.) periods within a paragraph

I'm trying to replace all periods with the degree symbol. Using the each method only replaces the first period inside the paragraph tag, not all of them. I'm also trying to make the periods inside the anchor tags to be ignored and not replaced, so the links won't be disrupted by my code. Can anyone help? $('div.post').each(function(){ ...