is it possible to read contents of a div from another html using jquery? -


Trying to read the contents of my DIV, which resides in a separate HTML file and engages in some existing page Is it possible? I know that the load is (), but it shows the whole html as it is.

  $ (".myDiv") .each (function () {// do stuff}); I have tried to load $ ('# result'). Load ('ajax / test.html #container') path, but it loads content with # div from divas # in the ID from container. I want to read the content of the div from ijax / test.html from id #container , Make some changes, then display it in the div # id #result ... trying to use every function on the div stays on another page, hope to make some sense  < / Div> 

.load () can load pieces of the page . Example call from Docs:

  $ ('# result'). Load ('ajax / test.html #container');   

can only load from div id #container to test.html , ID Load

Update

div with #result For & amp; Modify the content under which you need .ajax () method, such as

  $. Ajax ({url: 'yourfile.html', type: 'GET', data type: 'html', success: function (data) {var $ content = $ (find). ('. MyDIV'); if ( $ Content.length) {$ content.find ('p'). Text ('modified'); $ ('# some_local_id'). Attachment ($ content);}}});  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -