Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

jquery using variables

Posted on 2012-03-31
3
Medium Priority
?
271 Views
Last Modified: 2012-08-13
Hello Experts,

I am after understanding function and using variables with jquery.
I have a solution that does not seem to work (code below) and i would be thankful if someone can help me finalize it.

The variables are:

places-x  e.g.   places-1 ... places-2 ... places-3
mb-x  e.g.    mb-1 ... mb-2 ... mb-3

Here is the code but it does not work


for (var i=1; i<= 15;i++) 
	{
		var $position;
	    $('#places-+i').mouseenter(function(){
		$position = $('#mb-'+i).position();
		$('#standort-img').stop().fadeTo(100, 0.7);
		$('#mb-'+i).addClass('mb-zindex');
		$('#mb-'+i).stop().animate({width: 24, height: 24,top: ($position.top - (8/2)), left: ($position.left -(8/2))}, 100);		
		
		}).mouseleave(function() {
		$('#mb-'+i).stop().animate({width: 16, height: 16,top: $position.top, left: $position.left}, 100);
		$('#mb-'+i).removeClass('mb-zindex');
		$('#standort-img').stop().fadeTo(200, 1.0);
		});
	}

Open in new window

0
Comment
Question by:Refael
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Assisted Solution

by:animecyc
animecyc earned 1000 total points
ID: 37791707
From a quick glance of the code I can see one problem right off the bat:

 $('#places-+i').mouseenter(function(){

Open in new window


should be:

 $('#places-'+i).mouseenter(function(){

Open in new window

0
 
LVL 12

Accepted Solution

by:
Anuradha Goli earned 1000 total points
ID: 37795592
You have used apostrophe mistakenly  suppose

'#places-+i' should be changed to '#places-'+i
0
 

Author Closing Comment

by:Refael
ID: 37821869
Thank you!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question