jquery-selectors

jQuery selector

Hi how can i select and add a class to the prev and next a tag. <div class="sub"> <ul> <li><a href="#">a</a> <ul> <li><a href="#">b</a> <ul> <li><a href="#">c</a></li> <li><a href="#">d</a></li> <li><a href="#">e</a></li> </ul> </li> <li><a href="#">f</a></li> <li><a href="#">g</a></...

Selectors: Id vs. context

I use jQuery. I have been reading a lot about selector performance and optimizing our AJAX app. I am looking to improve my selector performance. I know all the jquery performance tips. I haven't found an exact answer to a question I have. I am using almost every current jquery performance tip and yet my app still seems to lag quite a bi...

How do I reference a hidden input in a specifc form using jQuery?

Hello, I have a series of forms on a page that all have a recordId value as a hidden input. The form name/id is GPA-Entry-Form-1. I am trying to get the value of the hidden field this way: $('#deleteThisGPAEntry-1').click(function() { var recordId = $('GPA-Entry-Form-1 #recordId').val(); alert('You clicked me. ID: ' + recordId)...

jquery dynamic id selector, remove then add class

Hi I have a table, with rows which all have a cell of a div with a dynamically generated id in the format of btn-insertidhere. When the table row is selected, I want to select this div id, then remove a class and change it to another one. This is down to me wanting to have a button image change from an add symbol to a delete symbol whi...

find immediate tr elements of table element using jquery find()

I am trying to find all tr elements inside a table element. The table element it self has other table elements nested inside its rows. So when I do the following: $(tbl).find('tr').hover(...); ...it picks up tr elements inside the nested table elements also. I just want the immediate tr elements of the table element I am trying to que...

Changed the HREF of a link w/JQuery, new link won't work.

Hi all, I'm fairly new to JQuery and Javascript in general. I don't think I'm trying to do anything too tricky, but this has me stumped. I have a series of links on my page which trigger a certain behaviour within the page when clicked. Once they are clicked again, they are supposed to jump to another page, but, using my current code, ...

jquery: how are HTML elements ordered when I select them using jquery selector

Hi, Is there some documentation regarding the order of returned HTML elements by a jquery selector. So for example if I do $('div.experience_entries_list input.experience_order_array').each(function() { alert(this.value); }); , can I assume that the returned elements will come in the order that they are positioned in the html? I...

Attaching events to flat ajax response html with jquery

In the application that we have, we're doing some AJAX response. Once in a while we get back a response that isn't fully contained Test 3 in the code below. While it's possible to beat people into submission, I would like to just build in some belt and suspenders in the code to handle the case. The key is the findself() function which...

Get element Attributes using jQuery

following is my HTML HTML : <div Attr1 = "val1" Attr2 = "val2" Attr3 = "val3" > Hello !! </div> I want to extract all the attributes (& its corresponding values) of an element. How can I do this using jQuery? I tried something like below, $(function() { for(var i in $('div')[0].attributes) { console.log($('div')[0]....

How can I hide a ul inside li?

Please tell me how can I hide ul child element inside each li, by clicking li link. I mean if someone clicks Alink, A1 and A2 hides. This is my HTML code : [Code missing] And here is the jQuery code, but it doesn't work :( $(document).ready(function() { $("#ListGrayCircle li").click(function() { $(this).find('ul').hide(); ...

Select an exact element and not its children

I have a menu like this; <ul> <li><a>1</a></li> <li><a>2</a> <ul> <li><a>3</a></li> <li><a>4</a></li> <li><a>5</a></li> <li><a>6</a> <ul> <li><a>7</a></li> <li><a>8</a></li> <li><a>9</a></li> </ul> </li> </ul> <li><a>10</li> </ul> If i want to make an selection on the 2nd level with jQue...

Why is this jquery script only targeting 1 element?

Take a look at this link http://dncminneapolis2012.com/new2 If you click on "two", it slides to the second page, and you see 4 boxes on the left. If you hover over the first one, it fades nicely to another image. My question is why isn't it doing that for all of the boxes? My html looks like this <div class="facts" style="width: 4...

jQuery selector : selecting ancestor whose descendent has attribute set to value

Struggling with CSS selector. Want to select all FORM elements that are ancestors of {elements having class='required'}. Any ideas? ...

How to Load/Replace an Entire DIV from an External HTML File

Hi, I have the following index.html page set-up: <html> <head> </head> <body> <div id="container"> <div id="header"> </div> <div id="sidebar_menu"> </div> <div id="thecontent"> <div id="page_banner"> </div> <div id="page_content"> </div> <div id="page_foote...

How to bind jQuery events on multiple PREDECLARED jQuery objects

Hi, This is how to bind multiple events on a couple jQuery selectors: $('#selector1,.selector2').bind('event', function (e, ui) { // Stuff }); But! How do you bind on predeclared jQuery objects. Example: var jSelector1 = $('#selector1'); var jSelector2 = $('.selector2'); Because, the following doesn't work: jSelector1,jSelec...

jQuery: How do I apply .blur to *every* child element of a div, rather than *any* child element of a div?

Hi all, I'm creating a Facebook-style "What's on your mind?" toggling input box. The way that I'm approaching it is a click and blur combination. Clicking an input box will auto-expand the container div and display a number of elements. This works fine. However, I have had trouble making it so that when the focus leaves every child elem...

Why isn't my script responding to class changes?

I have been using jQuery for some time and this one's stumping me- I really hope I'm just brain-farting! I have the following JS: $(document).ready(function(){ $('.thumb,.link').click(loadContent); }); function loadContent() { alert(this.id); if(this.id == 'contact') { $('#thumbs').hide(); $('#content').show().l...

How can I attach some jQuery to a function that already exists?

I have the following mark-up: <dt> <input id="p_method_checkmo" value="checkmo" type="radio" name="payment[method]" title="Check / Money order" onclick="payment.switchMethod('checkmo')" class="radio" /> <label for="p_method_checkmo">Check / Money order </label> </dt> <dt> <input id="p_method_ccsave" valu...

How can I highlight every single word in jquery so that I can provide a definition for each word?

What I am trying to do is allow the user to scroll over any word on a web page and when the mouse goes over the word it is highlighted (I know I can use hover for that). However I do not know how to select individual words, from the paragraph. The ultimate goal is to allow the user to click on the word and a definition appears over the...

jQuery - How can i dynamically add a list item to an unordered list?

Seems like a simple thing to do (although im still learning the ins and outs of jQuery). Here's my HTML: <div id="fbsignup"> <div class="message messageerror"> <strong>There were errors with your registration:</strong> <ul></ul> </div> </div> Here's my (attempted) jQuery: // Check Required Fields. $('#fb...