JQuery :: Targeting Multiple Elements
Dec 24, 2009
I am putting together a validation function and am having trouble with targeting multiple elements.[code]an onclick event fires my validation function. If any of the fields are empty, the appropriate error message should display.This sort of works. If all of the fields are empty, only the error message of the first element is displayed, not all 3.
View 1 Replies
ADVERTISEMENT
Nov 24, 2010
My HTML:
<div class="home-button">
<span><a href="#" style="">Button</a></span>
</div>
I have an instance of a div (button), inside this div is a link wrapped in a span. When you hover over the div (".home-button")I want to move the background position inside its "span a", I've achieved this using the code below.
[Code]...
View 1 Replies
View Related
Sep 27, 2010
I am using jquery with the cookie plugin and I have multiple image buttons that can hide/show multiple elements. My question is how can I add a cookie to this code to remember whether each separate element is opened or closed?
The code,
$(document).ready(function() {
// choose text for the show/hide link - can contain HTML (e.g. an image)
var showText='<div class="expanddown"></div>';
var hideText='<div class="expandup"></div>';
// initialise the visibility check
var is_visible = false;
// append show/hide links to the element directly preceding the element with a class of "toggle"
$('.toggle').prev().append('<a href="#" class="togglelink">'+hideText+'</a>');
// capture clicks on the toggle links
$('a.togglelink').click(function() {
// switch visibility
is_visible = !is_visible;
// change the link depending on whether the element is shown or hidden
$(this).html( (!is_visible) ? hideText : showText);
// toggle the display - uncomment the next line for a basic "accordion" style
//$('.toggle').hide();$('a.toggleLink').html(showText);
$(this).parent().next('.toggle').slideToggle('fast');
// return false so any link destination is not followed
return false;
});
});
HTML,
<a class="togglelink" href="#"></a>
<div class="toggle">
Content
</div>
View 6 Replies
View Related
Mar 11, 2011
I have following little script that applies to my entire html page:
$("td[id*='MSOZoneCell_WebPartWPQ']>table>tbody>tr>td").each
(
function()
[code]....
View 19 Replies
View Related
May 19, 2010
i have a xml document (static) that I need to test what is in a grand child element. The real application is a jqGrid. I have a onSelectRow operation going on. I can click on a row and get a response (in a alert window) for any root children. But how do I do this for anything deeper in the tree? A portion of my xml is attached.
[Code]...
View 2 Replies
View Related
Apr 29, 2010
I have a JQuery lightbox popup but am struggling how to control the content of the lightbox. all the examples given on the internet are from anchor links that are fixed. I however, need to use it from images pulled from the database so therefore the content will be different depending on what image is clicked. I already have the content I need in a div, so is there a way of targeting that div so it is displayed within the lightbox?
View 2 Replies
View Related
Jun 10, 2009
I've selected multiple tables and tried to use each for applying cornering to each table. Inside the callback function, I try to find the first/last table cells to apply cornering for each corner. However, when there are multiple tables it looks at _all_ the tr elements for the first/last rows. See example code:
// Add cornering to tables
$('table.corner-me').addClass('ui-corner-all').each(function(){
var $table = $(this);
$table.find('tr:first :first-child').addClass('ui-corner-tl');
[Code].....
View 1 Replies
View Related
Apr 11, 2011
Can someone explain to me the best way to loop through the geocode and marker (google maps) part of this code for all of the elements with the "address" class using jQuery (or javascript if need be). I tried wrapping the contents of the codeAddress function in $(".address").each(function () {... and replacing the getElementById with a jquery selector, but I still seem to be lost.
[Code]...
View 2 Replies
View Related
Oct 2, 2010
I have this query that does what I want it to do, find the class and remove an extra element within its parent:
$(".emptyTopNavOption").parent().children().first().remove();
But when there are multiple classes, it only deletes the first element in its query. As a successful test, I appended some CSS to ensure the query selected all classes and added a border to each element. So why does remove() not work? Is it a bug or is my query missing something?
View 1 Replies
View Related
Nov 14, 2011
I just started using jquery a few days ago and am already addicted.Now I am trying to figure out one thing which I can't seem to get answered by Google:I am building a dynamic website where at one place there will be an unclear number of div-elements. So there can be none, just one or several.The plan is to show them by a click on a button via slideDown(). So I wrapped them with another div.wrapper via wrapAll(). This works nicely for any number.Now the thing is: if my .wrapper has no specified height, the slideDown jumps - which doesn't look very nice.So I gave it a height:$('.wrapper').css({'height': $('div').outerHeight()});Presto, the animation works smoothly. But this works only if there's just one div.
View 2 Replies
View Related
Aug 18, 2010
I am performing the same animation three different times on three different elements. Is there a more efficient way to do this?
Here's my code:
$('.tier1').animate({opacity:.2}, 500)
$('.tier2').animate({opacity:.2}, 500)
[code]....
View 1 Replies
View Related
May 18, 2010
Is it possible to duplicate a few form elements on click of a button? For example if we have a form with the following fields:
1. Name
2. Address
and we have a button that says add a member
on clicking of which the same two fields above should be added:
1. Name
2. Address
View 1 Replies
View Related
Jul 5, 2011
Im working on a ajax app and not sure what is the best way to bind events to elements (performance wise).I have a number of elements with 'click', 'focus', 'keydown' events which can be assigned though the delegate to the parent, like so:$('#parent').delegate('#child', 'click', func.....)but is it better to add a delegate to the 'document' for multiple events and use IF statement to filter for elements which should fire an event, like so:[code]Each element can be replaced with an updated version retrieved from the server.
View 2 Replies
View Related
Dec 21, 2010
I am learning jQuery now and have a big interest in this javascript framework. I am trying to bind an event to more than one element. I won't meet any problem if using selector. But now, I've created a function which I will pass the element. And I need within this function, to bind the code. This is my current code :
function updateDay(dayObj, monthObj, yearObj){
//I want to bind both monthObj and yearObj.
yearObj.change(function(){
//do something
});
monthObj.change(function(){yearObj.change()});
}
$(document).ready(function(){
updateDay( $("#day"), $("#month"), $("#year"));
});
As you can see, I must bind twice, once for yearObj, the other for monthObj. Is there anyway to bind the change() event only once? If there are some logic mistake in using function or such as feel free to point out, since I still haven't read all the documentation yet.
View 1 Replies
View Related
Sep 9, 2010
Im trying to get 2 elements to execute some effect individually at the same time on a hover.Ive looked at .animate but if I understand it correctly I can do multiple effects but still limited to that single element.[code]So basically Im just trying to get 1st & 2nd on hovers to happen at the same time and 1st and 2nd off hovers to happen at the same time.
View 1 Replies
View Related
Nov 1, 2011
I'm wondering how to get access to each element I selected e.g. by the :has()-Selector. To explain a bit more: I want to select several elements and add to each of them attributes, but a different one to each element. So how can I run through the elements and modify each one?
View 3 Replies
View Related
Aug 4, 2010
Selecting elements using multiple parameters like here: $('descendant', 'ancestor').text(); seems to be way more popular than css-like syntax: $('ancestor descendant').text(); Do those two differ in performance, or is it just about being intuitive to particular people?
View 1 Replies
View Related
Aug 12, 2010
I am creating an FAQ type page with rows of questions that will drop down the respective answer when clicked. I have it mostly working, except I can't find a way to close all answers before opening the next one. I have tried everything I can think of (or search), but to no avail. I am using the following code, where QQQ1/2 are the questions, and AAA1/2 are the answer divs:
//Question/Answer
$(".QQQ1,.QQQ2").click(function () {
// check the visibility of the next element in the DOM
if ($(this).next().is(":hidden")) {
[Code].....
View 2 Replies
View Related
Mar 6, 2011
I'm quite new to jquery and i would like to know the best syntax to create an object with couple of DOM elements. I mean something like this:
[Code]...
View 2 Replies
View Related
Jun 13, 2009
I'm customizing the cycle plugin a bit from [URL] , which slides through a number of items.The issue I have is selecting a child object, to get its 'alt' attribute, and display it as a description. Using the default example:
function onBefore() {
$('#output').html("Scrolling image:<br>" + this.alt );
}
...works great when each item is an image. But I need to link each element, so my markup looks like this:
<div id="slideshow1" class="pics">
<a href="portfolio.html" title="Go to Project"><img src="tree.jpg" width="200" height="200" class="featuredimage" alt="Tree Branches" /></a>
[code]....
I'm not sure how to get the child element's alt attribute. I've searched through jQuery documentation and googled around, but can't get it working.
View 1 Replies
View Related
May 6, 2011
I'm working on the validation plugin for jquery and trying to figure out how I can target the text boxes that are dynamically generated with this change event. I'm trying to target them so I can set up rules for my page.
[Code]...
View 11 Replies
View Related
Nov 17, 2011
I'm trying to use a :not statement, so if you click anywhere else on the page BUT the element in the :not a div will disappear. When i use the same statement without the not, it works fine (click that one element and the div in the function hides).I'm assuming that the :not statement isn't working because the element is a child of its parent, so when you click it, essentially you are still clicking the parent which isn't included in the :not.
j(':not(.arrow)').live('click', function(e) {
j('.label').hide();
});
View 9 Replies
View Related
Oct 18, 2009
I'm writing a bookmarklet which allows you to select various elementsfrom a page and save them to your own personal blog (a bit likeffffound or the Wordpress PressIt feature)The user will select 3 parts from the page they want to save:1) Title (easy, just detect a click on an html element and make sureit's a span/p/h1/h2/h3 etc)2) Image (i've figured this out too)3) Body textI'm stuck with grabbing the body text - I think it should be selectedmanually, as it could consist of multiple p's and div's, or even tablerows, depending on how badly the source page has been coded.When the use has selected the text, it should be highlighted somehowen/browse_thread/thread/6dbbfd9cafd98cf6,I know that getSelection won't work, but I'm not sure what to doexactly.
View 1 Replies
View Related
Apr 13, 2010
The default behaviour for a class selector is: "An element can have multiple classes; only one of them must match." Is there a class selector where you can use multiple classes and all of them have to match?
View 1 Replies
View Related
Mar 23, 2011
just a very basic question. Have a div (id - photos) with multiple images. 1) Does this select them all? $('#photos img') 2)If so, how can i capture this information? Like so -> var bunchOfStuff = ($('#photos img')); and 3) if so, why can't i do something like alert(bunchOfStuff.length)into code tags...
View 3 Replies
View Related
Feb 4, 2011
Is there a cleaner way of creating a mixture of different elements and adding them to a page e.g.
[URL]
View 1 Replies
View Related