更新时间: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.