JQuery :: For Looping To Reduce Code
Sep 22, 2009
I have 5 buttons all using the same code:
$(".but1").mouseenter(function(){
$(".but1>.launch").animate({ left: "10px"}, 250 );
});
$(".but1").mouseleave(function(){
$(".but1>.launch").animate({ left: "0px"}, 250 );
});
$(".but2").mouseenter(function(){
$(".but2>.launch").animate({ left: "10px"}, 250 );
});
$(".but2").mouseleave(function(){
$(".but2>.launch").animate({ left: "0px"}, 250 );
});
$(".but3").mouseenter(function(){
$(".but3>.launch").animate({ left: "10px"}, 250 );
});
$(".but3").mouseleave(function(){
$(".but3>.launch").animate({ left: "0px"}, 250 );
});
$(".but4").mouseenter(function(){
$(".but4>.launch").animate({ left: "10px"}, 250 );
});
$(".but4").mouseleave(function(){
$(".but4>.launch").animate({ left: "0px"}, 250 );
});
$(".but5").mouseenter(function(){
$(".but5>.launch").animate({ left: "10px"}, 250 );
});
$(".but5").mouseleave(function(){
$(".but5>.launch").animate({ left: "0px"}, 250 );
});
Is there a way to do this in fewer lines of code?
View 12 Replies
ADVERTISEMENT
Oct 25, 2011
So, the aim of what I'm doing is to take any amount of text that's in a <textarea>, split it wherever there's a '=====\n' and then call each element of the newly created array back into the <textarea> in a sequential manner.[code]For some reason, my for loop doesn't work. It's only returning the last value in the array and disregarding the previous ones.
View 3 Replies
View Related
Apr 17, 2011
I am trying to set up a looping structure that tests to see if the user enters a value. If the textbox is null then a global variable is false otherwise a checkbox is checked and the global variable is true.below is what i have done so far.
var isValid = false;
window.onload = startForm;
function startForm() {
{code}....
View 2 Replies
View Related
Aug 14, 2010
I found out that (after an system update?) IE8 no longer loads the content on my website www.beautifullalaland.com. I guess it has to do with the ridiculous amount of jQuery calls that some of the simple functions requir. using JS for years but never a library (and never again if you ask me, what a bloody mess).
Is there a safe way to combine jquery_002.js, jquery.js, jquery_003.js and jquery-1.3.2.js?
View 9 Replies
View Related
Mar 18, 2010
How can I reduce the size of this calendar that it was built by jQuery UI?
PHP Code:
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker();
});
</script>
<div id="datepicker"></div>
[URL]
I like that calendar but it is too big for my website...
View 5 Replies
View Related
Jan 3, 2011
I need to implement a function called map (it needs to be written using reduce) in the below code that takes an array (arr) and a function (iter) as its arguments and returns an array with all its items transformed by iter, e.g. map([1, 2, 3, 4, 5], function(x) {return x * 2;}) should return [2, 4, 6, 8, 10]
View 6 Replies
View Related
Nov 22, 2011
I have this function that works well, but I ask ... is it possible to have a compact sintax to reduce the number of the char inside the text below ??
function change_txarea(val) {
if (val=='I') {
document.FrontPage_Form1.ob1.value = "Description " +[code3].....
View 5 Replies
View Related
Jan 26, 2011
If got problem with .each looping in jquery. im am trying to make a animation with jQuery. And i want to switch between three quotes of the array. and now it only works for the first quote of the array.
[Code]...
View 2 Replies
View Related
Jul 5, 2009
This is what i have. It does not correctly add two values when two checkboxes are checked. It should add up to 160 but it adds up to 20 instead! any ideas?
[Code]...
View 1 Replies
View Related
Aug 26, 2009
I have a function which is executed whenever someone clicks a checkbox on the page. There are lots of checkboxes on the page. I want the function to be performed on only the unchecked boxes. I've tried this two ways, neither of which has worked. Here are the two methods I've tried.
Method #1
$(".item input:unchecked").each(
function() {
if ($(this).val() > diff) {
[Code]....
Where diff is an integer and the values of the checkboxes are all integers. The problem is the function ends up getting run on all checkboxes, even boxes that have been checked.
View 3 Replies
View Related
Jan 7, 2010
I'm relatively new to JavaScript. I would like to loop through all the elements within a form and grab their values and what type of input they are. So far I came up with:
[Code]...
View 5 Replies
View Related
Dec 26, 2010
I have a problem with a function i created. I want an image to move from a to b and then start from a again. Without parameters this works really fine, but now that I have got more images I use parameters but I have no clue how to call the funtion again.
[Code]...
I tried to replace show(100,flo) with show(100,flo(zahl,r_g)) but then the divs only move from a to b but even will not come back to a again. I think the solution should be pretty simple but i cant figure it out.
View 4 Replies
View Related
Sep 15, 2011
I'm having an issue with looping a set of divs that are positioned on top of each other. When a link is clicked, the second div should fade in as the top div fades out, which coincides with another div changing background colour.As you'll notice, when the link is clicked for a third time, it loops back to the beginning by using the rel tag to keep track of what div is showing. The problem is that when it loops to the beginning the animation is not in sync with the second div changing colour.The code for all three is exactly the same and it doesn't matter how many coloured divs you have, it's always the last one fading out that causes the issue. The '#second' colour change fires after the box changes, not synchronised like the previous clicks.This is a basic example that I'm using on a site elsewhere so the concept of the second div fading in and then the first fading out is important - I can't switch so the first fades out then the second fades in.
View 1 Replies
View Related
Sep 13, 2010
I have a list of inputs
<div id="divID">
<input title="foo" type="text">
<input title="bar" type="text">
</div>
Then I'm trying to use jQuery to cycle through each input and ascribe ".attr("value") to each respective <input>. So far I've been using something along these lines:
var input = $('#divID input')
input.each(function(i) {
var title = input[i].attr("title");
input[i].attr("value", title);
}
If I remove the "[i]", it fills in every box with the title of the first <input>. If I leave it there, it fills in the first input, and then upon looping, says input[i].attr is not a function. So, if I type console.log(input[1]), firebug returns the correct <input> tag, but as soon as I add the .attr(); function, it blows up.
View 2 Replies
View Related
Jan 11, 2012
I was wondering if there way a way to loop through elements that contain a data key applied by data(). I couldn't find a selector for data keys.
This for instance, I would like to give me the value of 'foo' for where ever it has been applied.
$(document).ready(function() {
$('body').data('foo', 52);
$('head').data('foo', 32);
});
[Code].....
View 3 Replies
View Related
Jun 25, 2011
I want to loop thru all the hidden fields on the page, that have an ID which starts with "general_" and ends in "_10". Eg IDs:
id = "general_name_10"
id = "general_link_10"
id = "general_price_10"
How can I do such a loop in jQuery?
View 18 Replies
View Related
Jul 23, 2005
My program has divs that contain a single text node. I programatically set the myDiv.style.fontSize = "8pt"; When I call myDiv.offsetHeight, the number "14" is returned. I would like to be able to both predict the offsetHeight for various fontSizes and be able to reduce the offsetHeight.
View 10 Replies
View Related
Nov 6, 2011
I have a query that gets the url, modifies it and reloads the page.
The problem i have is that it keeps looping the reload, how to stop the loop?
Here is the code.
View 2 Replies
View Related
Oct 14, 2010
I'm trying to use the following loop to loop through dynamically created controls on my web form:
for(x = 0; x <= count; x++) {
Stmt += $("#DDLColumns" + x).val();
switch($("#DDLConditional" + x).val()) {
case "is equal": Stmt += " = ";
[Code].....
View 3 Replies
View Related
Oct 14, 2009
I am trying to make my own jquery drop down menu. As usual, HTML is like this:
<ul class="menu">
<li class="parent item79"><a href="#"><span>Top Item 1</span></a>
<ul>
<li class="item101"><a href="#"><span>Sample sub-menu 1</span></a></li>
[Code]....
...it doesn't work. Top menu shows, but drop down on hover doesn't show.
View 4 Replies
View Related
Jul 18, 2010
I would like to loop through elements that are NOT disabled. So far my code is:
$("#addlivestock :input").each(function(){
if($(this).find().attr('disabled','disabled'))
{
var getAttr = $(this).attr("name");
[Code]....
When I click a button that code fires. When that code fires all the elements that aren't disabled get disabled. My code does NOT work as expected and I found the problem, which is if($(this).find().attr('disabled','disabled')). how to loop through form elements that are NOT disabled.
View 2 Replies
View Related
Apr 23, 2010
I have a quandary of sorts here dealing with a list of checkboxes and the hiding/showing of a few divs associated with the checkbox selection. Here's basically what I need to do: Hide the lower div if no checkbox is selected. If any one of the first 6 checkboxes are selected, and NOT any of the remaining 6, then show the div. If at any time during selection one of the remaining 6 checkboxes are selected, then hide the associated div. Note this code doesn't really do much. I'm still trying to architect a solution that's best.
var aThroughf = false;
var gThroughl = false;
$('[name="'+q2030.name+'"]')).live('click', function() {
[code]....
View 16 Replies
View Related
Sep 6, 2011
take a look at following link and let me know how I can add a loop to my script in order to repeat the animate() function for example for every 30 seconds?
[URL]
as you can see the animate function just runs for one time but I would like to repeat it for every 30 seconds. I also would like to add a function to stop the animation when user mouse over on the Logo div.
Here is the code
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Moving Div</title>
[Code].....
View 2 Replies
View Related
Sep 6, 2011
take a look at following link and let me know how I can add a loop to my script in order to repeat the animate() function for example for every 30 seconds?[URL].. as you can see the animate function just runs for one time but I would like to repeat it for every 30 seconds. I also would like to add a function to stop the animation when user mouse over on the Logo div.
[Code]...
View 1 Replies
View Related
Aug 11, 2011
I am having a table that contains columns with rowspan and rows that do not contain rowspan. I want to read the date column from the table belowI want to read Monday 1 jan 2010, Tuesday 2 jan 2010. Wednesday 3 jan 2010...etc.
View 2 Replies
View Related
Jun 7, 2010
I don' t know what I'm missing here..
$("div#carousel a").each(function(i) {
$(this).click(function(e) {
e.preventDefault();
console.log(myArray[i]);
});
});
it doesn't loop, it always prints the first item in the array (there are 18 <a>'s inside div#carousel, and 18 items in the array...)
View 4 Replies
View Related