JQuery :: Access Original Selection Inside .each()?
Apr 11, 2010
Something I was wanting to do with jQuery the other day was to obtain a reference to the original selector from inside the each function. I was looking through the documentation and for the life of me couldn't come across a suitable solution.I had to use an external variable instead and reference that from within the function, which seems to be a non-optimal solution.
Code javascript:
$('li').each(function () {
// how to reference the $('li') selector from in here
[code].....
View 5 Replies
ADVERTISEMENT
Oct 22, 2009
I'm having some problem with return value for a function. I'm trying to access google blogger's API to display blog entries on my site. I'm doing this through JQuery and requesting a JSON response. Everything seems to work ok, but I want to access the link for the blog entry. This is a subset of the "entry" object.
It's structured like this:
Entry:
title,
content,
link:
rel,
type,
href,
rel,
type,
href,
I want to get the link where the "link.rel == "self". To do this I have to loop through the link object (5 times). The loop and conditional statement works correctly, but I can't get the variable inside this loop back to my original function.
I have this code:
$.each(data.feed.entry, function(i, entry){
$.each(entry.link, function(j, link){
if(link.rel == "self"){
var postlink = link.href;
alert("link : " + postlink);
return postlink;
}});
alert(postlink);
});
View 2 Replies
View Related
Jun 14, 2011
I'm having problem with getting the checkbox state of a selected row inside table. I don't know if there is any specific function to determinate which row is selected so I've thought of the following... when the row is selected, style(background color) is applied to the tr element, so I thought that I could looked for the tr element which has that style and extracted checkbox state from it.
<table><tr>
<td>Text</td>
<td>Text</td>
<td>Text</td>
<td><input type="checkbox"/></td>
<td>Text</td></tr>
<tr style="background-color:LightBlue;">
<td>Text</td>
<td>Text</td>
<td>Text</td>
<td><input type="checkbox" checked /></td>
<td>Text</td></tr>
<tr><td>Text</td>
<td>Text</td>
<td>Text</td>
<td><input type="checkbox"/></td>
<td>Text</td>
</tr></table>
If we assume now that second row is selected, how would I get the state of the checkbox (checked, unchecked)?
View 6 Replies
View Related
Jun 1, 2011
I want to detect if a checkbox is checked inside each item of a list element. If it is, I want to hide both the checkbox and the div text.
[Code]...
View 3 Replies
View Related
May 25, 2011
How can I access the "a" elements inside frameContent.html?I made the example files below as small as I could.[code]
View 3 Replies
View Related
May 4, 2010
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript">
var global_var = false;
function test_func() {
$.post("server.php", function(data){
alert("Data Loaded: " + data);
[Code]...
View 2 Replies
View Related
Apr 18, 2007
I need to access an element of my top window from inside an IFrame within that window.
I tried:
parent.MYFRAME.document.getElementById("LHS");
and i get a "Access Denied"
is there a way to do this?
View 5 Replies
View Related
Aug 17, 2010
In one of my functions I got the following lambda function. It works as intended, but I got a tiny problem. I'm trying to access the function-scooped variable "matched" and set it's value to "true". The problem is that it seems like the variable is existing as a local variable inside the lambda function, even if it's not declared inside the lambda function itself. So, the change "matched = true;" does not effect the variable that I declared.
Code:
//... code
var matched = new Boolean(false);
xmlhttp.onreadystatechange=function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
[Code].....
View 3 Replies
View Related
May 9, 2011
Well, it turns out IE8 has yet another problem. My code has a global variable (to the object) inside an object declaration that cannot be accessed by a function (that is also global).
The code is like so:
Code:
function myobject(params){
//public
this.initialize = function(){...}
//private
some variables...
//problem variable
var mouse = new Object()
mouse.x = 0;
mouse.y = 0;
//code...
slidecontainer = document.createElement("div");
slidecontainer.onmousemove = function(event) {
if(boo.isIE) {
e = window.event;
mouse.x = e.x + document.body.scrollLeft;
mouse.y = e.y + document.body.scrollTop;
} else {
e = event;
mouse.x = e.clientX + document.body.scrollLeft;
mouse.y = e.clientY + document.body.scrollTop;}}
//this function is in an interval
function moveslides() {
/* this is where I have the problem
It seems that the function doesn't recognize that mouse.x, or mouse for that matter, exists. Mouse is global to the object, so why can't this function access it?
*/if(mouse.x) {
code...
}}}
The page is at [URL] and works on every browser, including finnicky opera, except for ie. The full code is availabe when you right click and view the source on the page.
View 3 Replies
View Related
Dec 17, 2009
I have encoded same javascript file with "Microsoft script encode" and accidentally deleted the original file.There is a way to convert the encoded file into the original version.. The form of the encoded file is : <script type="text/jscript.encode">#@~^.....
View 5 Replies
View Related
Apr 29, 2011
is it possible to do document.getElementById("id-1").document,getElementById("id-2") in order to access an element inside another element
<div id="id-2"></div>
<div id="id-1"><div id="id-2"></div></div>
... i want to access the second element with id "id-2"
View 10 Replies
View Related
Aug 4, 2010
I have this code which doesn't work with jQuery but works without So, suppose the element in question has id 'xyz'.
Doesn't work:
Code:
doSomthing( $('#xyz') ) ;
Does work:
Code:
doSomething( document.getElementById('xyz') ) ;
The thing is, inside this function no jQuery is used! So is there a way to get the original element from the object returned by $('#xyz') ?
View 8 Replies
View Related
Jan 27, 2011
I'm new using JQuery UI and for some reason everything seems zoomed. The calendar appear big, the accordian widget appears big, everything is big. But the original form control don't appear with zoom and the browser has no zoom either.[code]
View 7 Replies
View Related
Jun 6, 2010
jQuery(document).ready(function(){
$( '#nav_Primary > li' ).hover(function(){
alert($(this).find('ul').outerHeight(true));
$(this).find('ul')
.stop( true )
.animate(
{height:'toggle'},
{duration: 600, easing: 'swing'}
);
}, .....
Once you load this up you will see that eventually the hover will not set the height correctly. Keep on hovering on each item and then leaving it before it fully expands and then the next time you go over it it will leave off where the last item had expanded to
View 3 Replies
View Related
Mar 20, 2010
I've got a number of divs with the prefix menu and the suffix where is say 1-10. My code is below. It assigns the click function fine to each, but assigns them all the function based on the last value of the for loop. (It calls the current value, while I want the value from when the code was originally executed to set up the click function). Scratching my head on how to accomplish this.$(function(){
[Code]...
View 2 Replies
View Related
Nov 14, 2008
I'm using this sortable method: [URL] Works perfect! I have one question though: When a certain action is taken by the user, I want to reset the original order of the <li>s in the list. I can't seem to figure out how to do that.
View 3 Replies
View Related
Aug 14, 2010
I have a table which contains multiple rows. The table has an unknown number of columns.
One of the TD's in the row has an 'A' tag containing the HREF property " /_layouts/DocIdRedir.aspx? somenumber" Let's call this TDSource and ASource
A sibling TD in the same row which has a class of ms-vb-title contains2 links- the'A' tagI want to update the HREF property of is in a DIV with a class of ms-vb itx . Lets call this TDTarget and ATarget.
The highlighted components are unique per row. I need to get the HREF value from ASource in each row and update the HREF value for ATarget in the same row.
It's my first day on jQuery - I understand that I can use children() to getthe TR containing the relevant TD's, and I can see how to use :contains() to identify the specific source HREF property, but I can't understand how to link these bits of information together to do what I want.
View 5 Replies
View Related
Oct 8, 2010
I'm using jQuery form plugin, but i want when when user clicks on a button to submit the form using the traditional submit, how can i reset the form to traditional one ?
View 1 Replies
View Related
Mar 26, 2010
The code below is jquery, and uses jquery's extend() [URL] function, but I don't think that the issue has anything to do with that... does it?
$(document).ready(function(){
var obj1 = {
"name": "spud"
,"age":32
}
var obj2 = obj1;
$.extend(obj2, {"location": "UK"});
console.log(obj1);
});
By my reasoning, obj1 shouldn't have location set. But it does. Is the line
var obj2 = obj1;
not making a copy of the original and leaving the original intact? Is it instead making some sort of reference to it? Why is changing the copy having an effect on the original??
View 6 Replies
View Related
Nov 6, 2010
I've been searching for about 3 days on this topic. I'm trying to get a template field inside of an ASP.Net detailsview control inside of an ajax updatepanel to work with the jquery datepicker. Very frustrating! I'm using VB with VS 2010. I can get the datepicker to work fine with a simple text box inside of an update panel but when I put it inside of a detailsview control it stops working.
View 4 Replies
View Related
Apr 1, 2010
I'm currently creating a simple shoutbox system. The whole shoutbox is in one DIV (shout_box). The DIV shows the 8 latest posts and below that you can enter a new shout / post. I used some script to submit the new post to a PHP page which fetches the data using Post. Then the script displays the message that the post has been added. This works great! However after 5 seconds I want the original DIV contents to reload (the 8 latest posts and the form to add posts. is that possible to do? I think it is, but don't really now where to begin.
I currently got the code below:
var dataString = 'message='+message;
//alert (dataString);return false;
$.ajax({
[Code].....
View 1 Replies
View Related
Jan 17, 2010
I use jQueryUI's tabs and when a user changes a form in the tab, it promprts the user that a change has been made. My question is, how do I revert the values before being changed when the user presses 'OK' on my confirm() prompt?
View 1 Replies
View Related
Aug 19, 2010
I don't know if this is a browser bug. I positioned a div at the bottom of the page just underneath the viewport, calculating it with $(document).height() and animate it to bottom:0, works great even when scrolling, cause of updating with the scroll-event. But when I reload this page or scroll down a bit the original position value was used, so it animates to the original viewport value.
View 1 Replies
View Related
Jul 22, 2010
I have a the SimpleModal running on a php page, and on said php page, a varaible is defined; e.g. $var = "John";
and then the usual gubbings for simpleModal, which calls modal_output.php - the file generating the output for the modal popup.
I need to get that $var into this popup, so the popup can read:
"blaa blaa John"
This should be simple, I thought - but I can't parse it through _SESSION, or any method I try. I even tried hacking it into:
$.get("contact_modal.php", function(data){
to read $.get("contact_modal.php?var=<?php echo $var ?>", function(data){
but that breaks the js
Is there anyway I can parse the variable from the original page into the modal popup page?
View 3 Replies
View Related
Oct 4, 2011
So I have a table. With jquery I change border properties of several td. If later on in the code those same td have their background color changed by jquery, their borders return back.
Even if nothing is changed, nevertheless after some time some of the borders would seemingly randomly suddenly show up. I am working on a maze so this really spoils the game.
Code:
if($("crush",xml).text()=='1'){
border1=$("border1",xml).text();
border2=$("border2",xml).text();
[Code].....
View 4 Replies
View Related
Jun 17, 2009
On my site here [url], I am using the coda slider effect I found here [url]. And on the tab entitled "Home Groups", there is a link "Home Group 1", which links to a fancy zoom box that I got from here [url].
But when I click on the fancy zoom text it scrolls the container a little to the right, and on some older browsers it returns to the original first container that loaded from the start.
Any idea where the effects are conflicting? or what code I would have to amend to make it work more fluidly?
View 1 Replies
View Related