?
Solved

jquery using variables

Posted on 2012-03-31
3
Medium Priority
?
270 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
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

764 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