Solved

jquery using variables

Posted on 2012-03-31
3
267 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
3 Comments
 
LVL 3

Assisted Solution

by:animecyc
animecyc earned 250 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 250 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

810 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