2
我想爲下面的腳本動態地獲取類名。如何動態獲取分頁插件類名稱?
我正在使用分頁插件。我有不同的類名是通過PHP創建的,所以需要動態地使用jQuery來獲取它們。
正如你在下面看到的,有兩個'#hiddenresult div.result'。 「結果」是靜態類的名稱需要改變,因爲類的名稱將與PHP
填充jQuery的文件:
<script type="text/javascript">
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();
});
</script>
感謝您的幫助。
感謝這個,但是我在上面的腳本中很難實現它。任何人都知道正確的植入? – 2010-01-21 18:03:44