I want to JQuery while defining a variable in PHP.
Suppose I have the following index.php file:
<!DOCTYPE html>
<html>
<head>
    <title>Page</title>
    <script type="text/javascript" src="../../../resources/js/common/jquery-latest.min.js"></script>
</head>
<body>
    <div class="bigdaddy">
        <div class="daddy">
            <header class="main"></header>
            <main>
                <aside>
                </aside>
                <article>
                    <div class="div1">
                        Sample1
                    </div>
                    <div class="div2">
                        <div> //Child 1
                            Sample2
                        </div>
                        <p> //Child 2
                            Sample3
                        </p>
                    </div>
                    <?php
                        // the code
                    ?>
                </article>
            </main>
            <footer class="main"></footer>
        </div>
    </div>
</body>
</html>
Questions:
- How can I select <div>with attribute and attribute valueclass="div1"to get its node/inner text?
- How can I select <p>child of<div class="div2">its node/inner text?
- Is it even possible to use jQuery in PHP?
Both questions are using jQuery
I thought of
<?php
    $answer1 = $('div[class="div1"]').html();
    echo $answer1;
    $answer2 = $('div.class="div2"').children('p').html();
    echo $answer2;
?>
But it didn't work.
Expected result should be:
Sample1 Sample3
EDIT: I can't use AJAX.
 
     
    
` inside `