Solved

jquery using variables

Posted on 2012-03-31
3
264 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now