473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

class name as variable

103 100+
How to use Jquery variable as css selector?

For instance,

Expand|Select|Wrap|Line Numbers
  1. <script>
  2. $(document).ready(function(){
  3.   var ind='th78'; //database row index
  4.   var classname='highlight ' + ind;
  5.   spanNode.className = classname; // set css
  6.   $(".highlight.ind").append("text from database with id=ind");
  7.   })
  8. // this does not work because there should be not word "ind", but value of variable ind. How to select value of variable ind?
  9.  
  10. //OR
  11. var spanNode = document.createElement('span');
  12. var ind='th78'; //database row index
  13. spanNode.id=ind;
  14.  $("[#id=ind]").append("text from database with id=ind");
  15. //This also does not work, because instead of ind, i have to compare with variable ind. How to use value of variable ind?
  16. </script>
I do not know how to use value of variable as Jquery/css selector.
Jun 21 '15 #1
1 1463
gintare
103 100+
Working example:
http://stackoverflow.com/questions/4...query-selector

they just add variable:
$('#'+ section_id + ' ul').children().size();

In my case it would be:
ind='th78';
$('span').attr('id', ind );
$("#"+ind).append("text from database with id=ind");
Jun 21 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Fu Bo Xia | last post by:
the java.lang.Object.forName method takes a java class name and returns a Class object associated with that class. eg. Class myClass = Object.forName("java.lang.String"); by if i only know the...
1
by: Penna Elabi | last post by:
Is class a variable? Can a variable consist of variables? For example, a vector is a class, so is this vector a variable when it includes two int variables: vector < int > exampleVector( 2, 2...
7
by: Klaus Johannes Rusch | last post by:
Is the following code valid and supported by current implementations? function somename() { this.show = function () { document.write("somename called") } } var somename = new somename();...
1
by: smeagol | last post by:
Look this code, well, you know how it works, in "public server (client cl) { cl.Write(); }" "client" is a know class name, but if somebody write a custom start class (like client) and it call to...
13
by: Brian | last post by:
I have many similar classes in a project, one for each type of report my app can create. I want to instantiate them based on a value passed in by a scheduler module. Right now I have Sub...
2
by: Rafe Culpin | last post by:
Does anyone please know of a way to access static methods of a class, when the name of that class is held in a variable? I have several classes (PHP5) which all have identically named methods and...
3
by: Janos | last post by:
Hi, I am a newbie, learning C#. I try to map the concepts I have learned earlier in other OO languages to the concepts used here in C# . In Smalltalk you have class variable, which is here the...
1
by: neoone | last post by:
Hi, I reported a bug to the bugtracker (issue 1443), but it was rejected with the comment: "Go ask on c.l.py why this is not a bug" After decrypting c.l.py to the name of this group, I'll do...
33
by: Peng Yu | last post by:
Hi, __PRETTY_FUNCTION__ is a macro that gives function name, etc. I'm wondering if there is a macro to get the class name inside a member function. Thanks, Peng
1
by: pata kusik | last post by:
I have a question about singleton design pattern and name of class as variable. I have a config file with value like this: $config="MyProjectDatabaseHandler" Then I aslo have class...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.