简体   繁体   中英

Pick A DIV Content Of Same Page And Show It On Same Page In PHP

I have a web-page in which there is some text like <h1 class="page-title">Some Text</h1> but I hide it through .page-title{display:none;} as I don't want to show it there. Now I want to show the same Some Text in another DIV of same web-page. This Some Text is dynamic but <h1> tag and class="page-title" is same on every page like <h1 class="page-title">...</h1> . I only want to show it through PHP as I can do it via JavaScript/JQuery.

I Googled many time but every time I am getting the code of picking the DIV content from other page but here I want to pick and show on the same page. Keep in mine the this Some Text is also generated by PHP so I think we need to post it again after this to allow him to load first then pick from there but I want to show it before Some Text on web-page. How to do this?

You cant execute PHP Script after the page has been loaded at the users browser, do you have all the php script in a variable at php? Then it could be possible to read the value before sending it to the user. Else there is only javascript possible

You need to add id to h1

    <h1 class="page-title" id="<?php echo $id;?>">some text</h1>  

// $id is the id of "sometext" in your table

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM