Showing posts with label jquery. Show all posts
Showing posts with label jquery. Show all posts

Wednesday, 9 August 2023

Select Child element and add css using Jquery

 Jquery  has a powerful DOM selection feature. You can select all child elements from a div or any other container and add CSS to those child elements.

Select all images from a div and change CSS using jquery


In the above UI , When a user clicks on an image A border is applied with padding. But when while click on another image border is applied but it needs to clear the previously selected image border. So the code given below help you to achieve this.
Border of all images inside of div id=''imgcon" will be removed by jquery and add a border on the selected image


<div id="imgcon">
    <img src="/Upload/notesimg/1014.jpg" id="img1014" onclick="ChangeCSS('img1014')" >
    <img src="/Upload/notesimg/1014.jpg" id="img1015" onclick="ChangeCSS('img1015')">
    <img src="/Upload/notesimg/1014.jpg" id="img1016" onclick="ChangeCSS('img1016')">
</div>
<script>
    function ChangeCSS(id) {    

        $("#imgcon img").css("border", "none");
        $('#img' + id).css({ "border": "solid 2px red", "padding": "2px" });

    }
</script>

Saturday, 12 November 2022

Select A Table all rows by checkbox using jquery

Select/Unselect  Table all row by clicking the checkbox using jquery. You can do this by class selector. Make a class and apply it on all checkbox and select or unselect using class name by just one line of code.

Name City
Ram Vns
Syam Alld
Gita LKO
Anita Vns

Code

<html>

<head>

    <title>Table Select</title>

    <style>

        .chk {

        }

    </style>

Wednesday, 6 October 2021

Show Date after Date gap in Date picker HTML

 This post help you to show date in date picker HTML form control from a given date gap. For example show date two date further from current date using HTML and JavaScript.