Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery selecting a selector with namespaced element

How would I select the following in jQuery?

<ns:text value="my value" />

I have tried the snippets below, but to no avail. Is this possible?

var x= $('ns:text').attr('value'); 
return x;

var x= $('text').attr('value'); 
return x;
like image 396
Val Avatar asked Jan 12 '10 07:01

Val


2 Answers

You're looking for:

var x= $('ns\\:text').attr('value'); 
return x;

Ref:

  • http://docs.jquery.com/Selectors#Special_characters_in_selectors
like image 173
K Prime Avatar answered Oct 21 '22 01:10

K Prime


Take a look at JQuery, XML and namespaces.

It seems that this should work:

var x = $("ns\\:text").attr("value");
like image 29
cletus Avatar answered Oct 21 '22 03:10

cletus