JQuery

How to apply border over image for a particular div element using jQuery?

How to apply border over image for a particular div element using jQuery?, someone asked me to explain?

In some situation we needed to apply border over the image for the particular div element id in jquery.We can set multiple css properties to border over image using jquery on pageload.

Example:

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Animated borderover image using css</title>
     <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#firstdiv').find('img').css("border", "solid 2px #2e9fff");
        });
    </script>
    <style type="text/css">
        .rect {
            width: 350px;
            height: 79px;
            cursor: pointer;
            padding: 5px;
        }
    </style>
</head>
<body style="border: 1px solid #DED8D8; width: 500px; height: 300px">
    <h2 style="color: #FF5722;">apply border over image for aparticular div element</h2>
    <div id="firstdiv" class="box">
        <a href="http://www.infinetsoft.com/" title="header logo image">
            <img src="http://www.infinetsoft.com/Images/logoinfi.png" class="rect" alt="header logo">
        </a>
    </div>
    <div class="box">
        <a href="http://www.infinetsoft.com/" title="footer logo image">
            <img src="http://www.infinetsoft.com/Images/footer_logo1.png" class="rect" alt="footer logo">
        </a>
    </div>
</body>
</html> 

Output:

apply border over image for a particular div element using jQuery

Post your comments / questions