Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get class names?
    primarykey
    data
    text
    <p>Hey, I am trying to get the class names dynamically for the script below.</p> <p>I have different class names that are created through PHP so need to get them using jQuery dynamically.</p> <p>As you can see below, there seems to be 2 areas where I need to get the class name. At the moment it is hard coded (the classes are named 'result'):</p> <p>1) var new_content = $('<strong>#hiddenresult div.result</strong>:eq('+page_index+')').clone();</p> <p>2) var num_entries = $('<strong>#hiddenresult div.result</strong>').length;</p> <p>so, I'd like jquery to get the class name instead of me just hard coding it in as seen below.</p> <p>The jQuery file:</p> <pre><code>&lt;script type="text/javascript"&gt; function pageselectCallback(page_index, jq){ var new_content = $('#hiddenresult div.result:eq('+page_index+')').clone(); $('#Searchresult').empty().append(new_content); return false; } /** * Callback function for the AJAX content loader. */ function initPagination() { var num_entries = $('#hiddenresult div.result').length; // Create pagination element $("#Pagination").pagination(num_entries, { num_edge_entries: 2, num_display_entries: 8, callback: pageselectCallback, items_per_page:1 }); } // Load HTML snippet with AJAX and insert it into the Hiddenresult element // When the HTML has loaded, call initPagination to paginate the elements $(document).ready(function(){ initPagination(); }); &lt;/script&gt; </code></pre> <p>Any help on implementing a solution would be great. Thanks </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload