Have a look of below example, that will show you , you have two p tag but you want to add div before “htmlbefore” class:

    <!DOCTYPE html>  
    <html>  
    <head>  
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>  
    <script>  
    $(document).ready(function(){  
        $("button").click(function(){  
            $("p.htmlbefore").before("<div>Hello india</div>");  
        });  
    });  
    </script>  
    </head>  
    <body>  
    <button>Insert content</button>  
    <p>This is a tutorial website.</p>  
    <p class="htmlbefore">This is a training institute.</p>  
    </body>  
    </html>  
Your Answer
Sign In
Enter email and password to comment or answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.