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; 回答1: You're looking for: var x= $('ns\\:text').attr('value'); return x; Ref: http://docs.jquery.com/Selectors#Special_characters_in_selectors 回答2: Take a look at JQuery, XML and namespaces. It seems that this should work: var x = $("ns\\:text").attr("value"); 回答3: I