473,396 Members | 1,599 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,396 software developers and data experts.

How to get class names dynamically? - jQuery

Hi there, I am trying to get the class names dynamically for the script below.

I am using the Pagination plugin. I have different class names that are created through PHP so need to get them using jQuery dynamically.

As you can see below, there are two '#hiddenresult div.result'. 'result' is the static class name that needs to change since the class name will be populated with PHP.

so, i want jquery to get the class name instead of me just hard coding it in as seen below.

The jQuery file:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3.         function pageselectCallback(page_index, jq){
  4.         var new_content = $('#hiddenresult div.result:eq('+page_index+')').clone();
  5.         $('#Searchresult').empty().append(new_content);
  6.         return false;
  7.     }
  8.  
  9.     /** 
  10.      * Callback function for the AJAX content loader.
  11.      */
  12.     function initPagination() {
  13.         var num_entries = $('#hiddenresult div.result').length;
  14.         // Create pagination element
  15.         $("#Pagination").pagination(num_entries, {
  16.             num_edge_entries: 2,
  17.             num_display_entries: 8,
  18.             callback: pageselectCallback,
  19.             items_per_page:1
  20.         });
  21.      }
  22.  
  23.     // Load HTML snippet with AJAX and insert it into the Hiddenresult element
  24.     // When the HTML has loaded, call initPagination to paginate the elements        
  25.     $(document).ready(function(){      
  26.         initPagination();
  27.     });
  28. </script>
  29.  
Any help on implementing a solution would be great. Thanks
Jan 23 '10 #1
1 6908
gits
5,390 Expert Mod 4TB
i assume that you have the JavaScript code written in the page? then you could just use php to write the correct values there ... otherwise, when the script is included with a script tag you might populate a JavaScript-variable to the page that you might use in the script later on ...

kind regards
Jan 25 '10 #2

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

Similar topics

5
by: Udo Gleich | last post by:
Hi, I try to implement mixin classes. Thats why I need to make a new class at runtime. --tmp.py------------------------------------- import new class K1(object):
3
by: Robert Oschler | last post by:
Hello, I am a Python newbie (by experience, not chronologically :) ), so if any of this doesn't make sense my apologies in advance. I am reading the chapter in The Python Cookbook on databases...
9
by: David A. Osborn | last post by:
I have a set of classes that each have an enumeration in them, and based on dynamic input I need to access a different enumeration. For example Three classes Class_A, Class_B, and Class_C that...
6
by: Gale | last post by:
I'm working on something in jQuery with XPath What I want to do is: if checkbox is checked, set background color od label that contain input(checkbox) to red I have this code:...
8
by: =?iso-8859-1?q?Jean-S=E9bastien?= | last post by:
Hello, I'm starting in rails and ajax. So i've a javascript question: someone could help me to update the class of a div? Regards.
5
by: ziobudda | last post by:
Hi, I want ask you if, for a web portal/application, is better prototype or Jquery? I don't want to innesc some type of flame, but after the announce that drupal use JQuery and that the new...
20
by: Aaron Gray | last post by:
There does not seem too be anyway to test if two jQuery references are the same element. Given :- ... <div id="1"></div .... Then :- alert( $("#1") == $("#1"))
26
by: RobG | last post by:
Do some of the regulars here need to re-think their (sometimes strident) opposition to libraries? Both Microsoft and Nokia have announced support for jQuery. It seems to have gained quite a bit...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
3
by: mberkom | last post by:
I've got a jquery selector I'm trying to get done and since I'm somewhat new to jquery I'm stumped. Essentially. I'm trying to get a div within divs with the class "card" that do not have the 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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.