jquery

jQuery dynamic selector

I have some code which uses a selector in a loop. This works: document.getElementById("new_grouping_"+i).value This does not: $("#new_grouping_"+i).value Is there a way to do this using jQuery? ...

Using jQuery to get json data returns invalid label error

I have this code, and have also tried something similar using the $.getJson function: jQuery(document).ready(function(){ var kiva_url = "http://api.kivaws.org/v1/loans/newest.json"; jQuery.ajax({ type: "GET", url: kiva_url, data:"format=json", success: function(data){ alert("here"); jQuer...

Need Regular Expression for Javascript string replace

I need a regular expression that will properly work, the current one I have is breaking. The goal is Normal src for an image is: Image.png Using jQuery on hover I dynamically find the src of an image and replace it with ImageName-Dn.png On hover off it sets it back to ImageName.png My current solution: $(document).ready(function()...

Can't the browser just use its cache from prior ajax calls?

I am trying to rely upon the browser cache to hold JSON data returned from AJAX calls in jQuery. Normal browser activity relies upon the browser cache all the time. Example: jpg and gif images are not refetched on a page reload. But when I try using jQuery getJSON ajax calls, I cannot seem to avoid fetching the data from the server. M...

Method delegation in Javascript/jQuery?

I have this code: var myWidget = $('#myWidget'); and calls like this elsewhere: myWidget.hide(); myWidget.slideToggle(); These work of course because jQuery adds these methods. Now, let's say I'm doing some refactoring to make myWidget a proper object with its own custom methods and state: var myWidget = (function() { // priv...

Comparing DOM elements with jQuery

I am working inside of a jQuery each iterator: $('p').each(function(){ ... }); I'd like to create an expression that evaluates to true when: $(this) is the last p element scope is $(this).parent() $(this) must be a direct child of $(this).parent() $(this) is not necessarily the last direct child of $(this).parent() Here are a few s...

regex in jquery

I need to provide the P.O Box validation for the address Fields Now we have a regex validation in jquery which has some limitations as follows: If an address polo Rd is given, it identifies "po" in polo and alerts error message. So, we should frame a new validation which should not accept address lines with the values: "PO BOX", "PO ...

How to highligh the row and column of a table when over a cell using jQuery?

I have a table 10x10 in html if I add a function for each td hover, how can I get the cell column and row index? Thanks. ...

jQuery - parsing JSON data - Having trouble with variable name

My first delve into working with JSON data. I have a bit of experience using jQuery though. I'm posting to this URL (tumblr api): jyoseph.com/api/read/json What I'm trying to do is output the json that gets returned. What I have so far: $(document).ready(function(){ $.getJSON("http://jyoseph.com/api/read/json?callback=?", functio...

How to save the $.getJSON returned value in JQuery

Hi, i am doing an application which make use of JQuery and Cakephp . In this i am using like the following to retrieve the values from my controller side var getformid; $.getJSON("http://localhost/FormBuilder/index.php/forms/getFormEntry", function(json) { getformid=json.forms[0]["id"]; alert("Form id inside "+getformid); });//jso...

Accessibility and code organization problems in javascript with jquery.

I'm having troubles with the order of my code in my program. right now I have some things with in document.ready(function() { } ); and some things out side of it. Whenever I move anything (to organize or improve my code) I end up breaking something, I'm guessing because of either order of declarations or access levels (ie. something outs...

how to use prev to get the value of an input field

I have an hidden input field with a value, <form> <input type="hidden" value="product"/> <select class="select" name="select3" id="select3"> <option>0</option> <option>1</option> <option>2</option> </select> </form> I need to get the value of input field once a button is click...

Adding Slide-to-Anchor to Hide effect

In jQuery: I'd like to create an link to on click shows a hidden div (got that working by now) but also slides to it with a smooth-scroll effect. How do I combine the two? Thanks so much. ...

Adding JSON results to a drop down list with JQUERY

I'm making a call to a page method via AJAX in my ASP.NET application via JQUERY's AJAX method e.g. $.ajax({ type: "POST", url: "page.aspx/GetDropDowns", data: "{'aId':'1'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { alert(msg.d); ...

Jquery ajax calls in ASP.NET webservice vs page method

I am making an AJAX call in my ASP.NET application via Jquery to a page method. $.ajax({ type: "POST", url: "APage.aspx/GetDropDowns", data: "{'AId':'1'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { alert(msg.d); }, error:...

JQuery firing before my data is loaded in the page controls

I am using ASP.NET MVC and jQuery. I have this code in my js file. It should hide and show certain divs when a user clicks on a radio button. I would also like to fire this on the page load using the trigger method. My problem seems to be that when the event is trigger my default values from the model haven't been loaded into the cont...

how to unselect a select option box after some calculation is done

Hi, just wondering how it's possible to un-select the select option box, i used .remove() but this actually removes the text from the select box, is there any other way. thanks ...

Setting the focus to the next input in jQuery?

Hi guys, I've currently got a script that'll check for the value of a select box, and then enable a text field right next to it, and then hopefully set focus. I have this at the moment which works fine at enabling the input field... $("#assessed select").change(function () { if($(this).val() == 'null') { $(this).next('input').attr("...

How to use JQuery, select element by ID and ASP.NET without putting ctl00_ everywhere in the code

I have about 600+ references of code similar to the following... $("#ctl00_ContentMainPane_eliteUser").html And changed the master template, only to find all the code had broken, due to the control hierarchy changing. All javascript is included in separate files, so I cannot use code such as this... $("#<%= eliteUser.clientID%>").ht...

Setting for attribute of a label element with object oriented method

Labels have a 'for' attribute which makes them point to a certain input field. I need to change the value of this attribute with JQuery so I could use: $("label").attr("for", "targetName"); But I also need to set the className, so i'd prefer to use: $("label").attr({ for: "targetName", className: "something" }); You might ...