Solved

jquery using variables

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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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…

728 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