JQuery :: Simplify The Following Expression By Avoiding Using Attr("id")
Sep 3, 2009
Has anyone now how to simplify the following expression by avoiding
using attr("id")
alert($("#"+$(obj).attr("id")+"~p:last").attr("id"));
I need this because not every image could have an id.
<script language="javascript" type="text/javascript">
function ExpandCollapseOnLeftPanel(obj) {
if ($(obj).attr("src") == "/Content/Images/arrow_bot.gif") { //
[Code]...
View 1 Replies
ADVERTISEMENT
Aug 17, 2011
If I had 12 element divs, how could I make a toggle function that work for all of them?
<div id = "element1">
<div class="question">1. Who wrote the book James and the Giant Peach?</div>
<div class="answer"><img src="images/cover.gif" class="top"/><p>Ronald Dahl</p></div>
</div>
[Code]...
View 2 Replies
View Related
Feb 8, 2011
Currently we have two forms on a single page. This is our jQuery
[Code]...
I've spent quite awhile reading documentation, how-to's etc, but I can' figure out how I can modify our jQuery so that we don't have a validate routine for each form. This is not a big deal for two forms, but some of our pages have five and more forms, so the jQuery would start to get long.
View 3 Replies
View Related
Sep 9, 2011
I have this working code:
$(document).ready(function() {
As you can see its numbers counting up to 31 in both IDs (its a calendar). Any way to put this in less lines?
View 3 Replies
View Related
Jul 28, 2009
What can I do to avoid animation repetition? because when I write an function and put to be executed onclick, if the user click more than one time it start to repeat...
View 7 Replies
View Related
Nov 12, 2010
I am trying to use some really simple jquery in a rails 3 app. I am trying to get a function to run whenever a rails 3 js callback is fired, the function is to add or remove css classes from link elements. But so far I keep getting errors in the console (chrome) stating that the object defined by my css selectors doesn't have the addClass and removeClass methods.Here is my code:
$(function($) {
var resetArtistTabStates = function () {
$("#artist-tabs li a".addClass("current"));
[code]....
The ajax:success event come from rails.js jquery file, which contains the following:
callRemote: function () {
var el = this,
method = el.attr('method') || el.attr('data-method') || 'GET',
[code]....
View 2 Replies
View Related
May 19, 2011
I know almost nothing about javascript... I am a designer. That being said, I need to code a zip code search form. There will be 2 or 3 different pages a user could get to depending on which zip code they enter. This is what I "borrowed" so far...
[Code]...
View 14 Replies
View Related
Jul 23, 2005
My HTML pages have a <SCRIPT SRC=http://remote/script> at the top'ish
of each page. Sometimes the remote host (probably due to heavy load or
flaky network connectivity) doesn't respond for a long time. This
causes the whole page to appear hanging without anything loading.
Is there some trick I can use with settimeout() so that if the remote
script cannot be loaded after, say, 30 seconds, then I can tell the
page/browser to cancel loading that script?
View 14 Replies
View Related
Jan 5, 2010
An application under development has a set of core functions that carry out common tasks and a 'machine' that animates panels of lists of names and menus and provides another panel for action calls. (see attached pic). Selection of a name identifies object(s) to be worked on and menu couplets like "Name+Edit" call devices (each in a separate js file).
Each js file replaces any files in the deviceScript holder in the hta file. I used to use eval(couplet+"Start")() to initiate the device, but having read about the evils of eval it dawned on me that it was unnecessary and just gave each device a start() function ... and also an optional refresh(), and compulsory finish() to pick up results and clean up.This seems to work well on my machine. The hta is intended to run locally picking up json type data and devices locally and via the net.
View 9 Replies
View Related
Aug 26, 2009
How can i get around of avaoiding a promplt when trying to close a window?
[code]
function NoConfirm(){
window.opener = top;
window.close ();
}
[Code]...
View 9 Replies
View Related
Aug 24, 2011
I'm trying to build a simple "where's the meeting room" page for my work. This consists of a background image of the map, and (right now), a red block absolutely positioned on the map to show where the room is.I'm using an object to keep track of x/y positions for the rooms, i.e.
Code:
var rooms = {
a123: {
x: 100,[code]....
This works, but uses eval() a lot, which doesn't seem like best practice. What's the appropriate way to get the info?Here's the whole page code:
Code:
<!DOCTYPE HTML>
<html>
<head>[code].....
View 2 Replies
View Related
Jan 19, 2010
I am building a website with a very plain main page. It displays some text but it also displays a random background avoiding scrollbars, etc. I've managed to do the random image thing, but I also want it to scale the random image. Also I have tried this same thing and I got it working but in a different file, I just don't know how to combine this two solutions. I attach the code of both files:
[Code]...
View 1 Replies
View Related
Jan 7, 2011
I have a spam problem with my online form in [url]
I keep receiving spam and what puzzles me is that the spam script does not need to fill the required fields to send the form.
I tried to add a math puzzle by inserting:
and
However, the hidden field still shows on the browser (it doesn't show the value but it shows an empty square) and I can't get the form check to compare the values of "Filtro" and "Solucionfiltro".
View 6 Replies
View Related
Apr 29, 2010
I have following code, that i am sure can be done in 1 single function, which will ease extending it in future.
Basically when a link is clicked, i wante the upload form to apear....and any other upload forms to disapear.
How can i put those 3 functions in 1?
View 1 Replies
View Related
Jul 12, 2011
I've been using 1.3 which allows me to query non-standard attributes on tag. On an anchor I set a value="" attribute and was able to say (in an onclick binding) $(this).attr('value') to get the value. This no longer works with 1.6. Is there another, better way to do this?
View 5 Replies
View Related
Jan 11, 2012
If the element i'm getting has an attr that contains string like this....
<span names="Joes|Joe's">Joes|Joe's</span>
When we get the contents of attr st, there is an error because of the ' in they're.
View 3 Replies
View Related
Jan 15, 2011
I have json object:
var heightwidth = '';
if (isit) {
heightwidth = { width: 184, height: 135 };
[code]....
View 1 Replies
View Related
Aug 4, 2010
I have a suggestion based on the assumption, which I think is correct but feel free to prove me wrong, that the .attr() method returns "undefined" in two different cases:1) when the attribute is actually not present in the dom element2) when it is present but it has no value, think for example <input type="text" disabled/> which I not is not standard HTML but I've seen it pretty often...wouldn't it be better to return undefined only in the first case, and return null in the second case? In this way, it'd be clear that the attribute is set but no value is specified.
View 2 Replies
View Related
Sep 16, 2010
I'm getting all kinds of errors, no matter where I put the parenthesis: This all works without trying to find the attr. So, I am trying to slide a ul menu that has a parent anchor with an id of "A". $(("#VerColMenu > li > a").attr('id')=='A').find("+ ul").slideToggle("slow");
View 4 Replies
View Related
Nov 2, 2011
I have two img tags and a jquery script which changes the value of the src attribute of each one picked from an array of images and alternatively set the display to block and assign a decreasing z-index.
The problem is that when the hidden image pops up, it seems as if, at first, set the css display to block and then change the source of the file as, for a second, it hangs to the previous loaded picture. Well I thought it was easy to manage by setting a delay but instead seems not to do anything. And then with a setTimeout but it doesn't work as expected..
[Code]...
View 1 Replies
View Related
Jul 13, 2010
I am trying to get a href attr from variable msg. The problem is that the msg consists of not only <a element but it contains also <p element and because of that attr doesn't give any value.
var msg="<p><a href='/users/'>Username</a> Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
var href=$(msg).attr('href');
how I can get the value of href from the above example?
View 2 Replies
View Related
Nov 26, 2010
Not really sure how the best way to start explaining this, but I have a small script set up that activates a second section to an accordion to display information. The idea is that a table cell will be clicked and then the second according will activate displaying information relating to the cell that was clicked in accordion part 1.
I have managed to get it to update coding in the var's by hand, now I want to be able to get certain bits of information from a nested div that is hidden in the table cell (I know, very messy - but it will all be made a little less messy in the future when I have got the process correct).
[Code]...
View 1 Replies
View Related
Mar 23, 2011
I've made a script to highlight an element when you rollover on another one.
// Highlight thumbnail on roll over post list item
$("#sidebar-left .left-col2 a").live("hover", function(){
var title2 = $(this).attr("title");
alert("title : " + title2);
[Code]....
My problem is that the script works fine but unfortunatly just for the first li element that I rollover...
How can I make it for each one?
View 4 Replies
View Related
May 17, 2011
I have a chunk of XML. An example would be:
<Input minOccurs="1" maxOccurs="1">
<ns1:Identifier xmlns:ns1="http://www.opengis.net/ows/1.1">DATASET_URI</ns1:Identifier>
<ns1:Title xmlns:ns1="http://www.opengis.net/ows/1.1">DATASET_URI</ns1:Title>
<LiteralData>
<ns1:DataType xmlns:ns1="http://www.opengis.net/ows/1.1" ns1:reference="xs:anyURI"/>
<ns1:AnyValue xmlns:ns1="http://www.opengis.net/ows/1.1"/>
</LiteralData>
[Code]...
Edit: Changed dataType2 usage in 3rd line to be a regular variable and not a jQuery variable. Also, this seems to not be working in jQuery 1.5.2 either and only for Opera. I had originally thought this was working for 1.5.2 but I just re-tested and it is not. What happens is that dataType2 is undefined after the call to pull the attribute. I've also now tried .attr('[nodeName="ns1:reference"]') as well as using the same with .prop() in jQuery 1.6.1
View 1 Replies
View Related
Oct 13, 2009
Here is the code
$(document).ready(function(){
$('img').attr({onclick: "Image_Click(src)"});
$('img').css("cursor", "pointer");
});
[Code].....
This works in Firefox but will not in chrome. In chrome the .css works and changes the cursor to the hand on hover however .attr does not work it doesn't put the onclick attribute on any of the images.
View 2 Replies
View Related
Sep 6, 2009
I am trying to set an html attribute after an AJAX call. Works great on the initial tab I can't get it to work on the rest [code]...
View 1 Replies
View Related