Can I make jQuery for an XML document and not for the DOM?

I am trying to modify the page to be read from XML, not the DOM, and I would prefer not to use $ (xml) .find ('blah') for each individual call, and I was wondering if there is a way to specify jQuery in xml rather than DOM

For example, I would like to be able to move my xhtml using the jQuery method as such: $ ('Blah'). That

Is it possible?

+3
source share
3 answers

No, you cannot redirect the global object documentto an arbitrary DOM document that you created.

jQuery context $() , :

$('blah', xmlDoc).whatever()

var, , , :

var $xml = $(xmlDoc);
$xml.find('blah').foo();
$xml.find('bloh').bar();
+2

, $:

var old$ = $;
var xml = ...;

$ = function(arg)
{
    return old$(arg, xml);
}

, ... ...

+2

jQuery.ajax() jQuery.get() DOM , / "json" "xml".

http://docs.jquery.com/Ajax/jQuery.ajax#options ( "dataType" )

+1

Source: https://habr.com/ru/post/1718743/


All Articles