Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

concatenate javascript jquery strings

Posted on 2012-09-11
2
Medium Priority
?
719 Views
Last Modified: 2012-09-12
var index = $(".root").index(this);

var top = 20 * (index + 1);
$("#resultsSchoolListDiv").find(".dropdownSchoolList").eq(index).css("top" + "," + "\"" + top + "px\"");
//$("#resultsSchoolListDiv").find(".dropdownSchoolList").eq(index).css("top",  "60px");

Open in new window


I need to set the css top property dynamically - I'm trying to achieve what is in the last line dynamically. How do I concatenate the string
0
Comment
Question by:sanagarwl
2 Comments
 

Author Comment

by:sanagarwl
ID: 38389652
Never mind - solved it using following syntax

 $("#resultsSchoolListDiv").find(".dropdownSchoolList").eq(index).css('top', function (value) {
                return top ;
            });
0
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 2000 total points
ID: 38390304
Just use this
$("#resultsSchoolListDiv").find(".dropdownSchoolList").eq(index).css('top', top);

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
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 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)
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

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