How to replace page title dynamically by popup box title? : <p>My index page contains popup box. I want to replace index page title by popup box title if popup box clicked. </p>

<p>For example</p>

<pre><code>&lt;title&gt;&lt;?php echo $title?&gt;&lt;/title&gt;
</code></pre>

<p>I want to display as following: </p>

<pre><code>&lt;?php
    if(condition){      (-&gt;*such as #model2 is clicked*)
        $title="Model2 Section";
    }
    else{
        $title="Home"
    }
?&gt;
</code></pre>

<p>I have used popup box as following:->
<strong>(link for popup box)</strong></p>

<pre><code>&lt;article&gt;
&lt;a href="#modal2" class="dsnbutton ybank" id="pop_button"&gt;Model 2&lt;/a&gt;
&lt;/article&gt;
</code></pre>

<p><strong>popup box</strong></p>

<pre><code>&lt;div class="remodal" data-remodal-id="modal2" role="dialog" aria-labelledby="modal2Title" aria-describedby="modal2Desc"&gt;
</code></pre>

<p><strong>How to change title ?</strong> Any Idea.</p>
