Hello and thank you for your help. I'd like to do something similar for my website.
Simply that the loading of the page, In php, I would like to take the content of a DIV.
And then display it anywhere on the page.
Store in variable $texte1 all the contents of the div id texte-1
<?php $texte1 = get_contents_div('text-1'); ?>
And put the content of the div in page
<?php echo ($texte1);?>
Tank you for help friends Sorry for my bad english
Use the php DomDocument class. http://www.php.net/manual/en/class.domdocument.php
$dom = new DOMDocument();
$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$divContent = $xpath->query('//div[id="product_list"]');
This is how you can do it in javascript:
<script>
(function(){
var divContent= document.getElementById("text-1").html(); //get div content
document.getElementsByTagName("body").append(divContent); //add it to the body
})();
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.