1

So I have this JS code:

var messages = xml;
console.log( messages );

which returns this:

<messages test='foo'></messages> 

How do I get "test", considering that the following does not work?

$(xml).find('messages').attr('test'); //returns undefined.

Thanks in advance.

Added jsFiddle: http://jsfiddle.net/yJy8L/1/

2 Answers 2

1

Try this:

 $(xml).filter('messages').attr('test');
Sign up to request clarification or add additional context in comments.

Comments

0

Please try this code

var xml = "<messages test='foo'></messages>", messages = xml;
 $(messages).attr('test');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.