且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过XML数据使用jQuery和HTML进行分页

更新时间:2023-02-12 21:10:56

the get() function returns the non-wrapped set element in this case it would be the xml element.

$.get('quiz.xml', function(d) {
    var question = $(d).find('question :eq(0)');
    var questionContent = question.attr('content');
    alert(questionContent);
    $(questionContent).appendTo("#quizQuestion");
});

the other alternative is to re-wrap the object

$.get('quiz.xml', function(d) {
    var question = $(d).find('question').get(0);
    var questionContent = $(question).attr('content');
    alert(questionContent);
    $(questionContent).appendTo("#quizQuestion");
});

Also, I'm not sure why your including the $(document).ready inside the function call. When are you calling the function. if its after the document load then you don't really need that.

相关阅读

技术问答最新文章