Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Friday, 5 March 2021

Add and remove a class on click using jQuery

 


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script>
jQuery(document).ready(function(){
jQuery('#btnSubmit').on('click', function() {
jQuery(this).addClass('toggle').removeClass('codepen');   
});
});
</script>

According To Question:

#jQuery add remove class onclick codepen
#Add Class jQuery
#jQuery Onclick Remove Class And Addclass
#toggle class jQuery
#Onclick Add And Remove Class To Body
#Add Class JavaScript
#jQuery Add Class On Click
#Remove Class In JavaScript
#Add Remove Class Onclick By jQuery


Saturday, 20 February 2021

Change Div Order In Mobile View By jQuery

 

Web View

                             
                           Before Change              After Change 



<html>
    <head>
<title>Change Div Order In Mobile View By jQuery.</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
        <style type="text/css">
           body{
padding:20px;
   }
            #container {
                width:100%;
                margin: 0 auto;
text-align: center;
            }
.display_inline{
border: 2px solid;
width: auto;
display: inline-block;
padding: 150px 100px;
margin: 22px;
font-size: 50px;
color: #fff;
font-family: emoji;
}
#div1{
background:#1a3a5f;
}
#div2{
background:#79286c;
}
@media only screen and (max-width: 600px) {
.display_inline{
width: auto;
display: block !important;
bolder:2px solid red;
padding: 10%;
}
}
           
        </style>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
    </head>
    <body>
       
        <div id="container">
            <div id="div1" class="display_inline">
<div class="center">
Div One
                </div>
                
            </div>
            <div id="div2" class="display_inline">
<div class="center">
                    Div Two
                </div>
            </div>  
        </div>
<script type="text/javascript">
function listenWidth( ) {
if (jQuery(window).width() <= 600) {
jQuery("#div2").remove().insertBefore(jQuery("#div1"));
} else {
jQuery("#div2").remove().insertAfter(jQuery("#div1"));
}
}
jQuery(document).ready(function(){
listenWidth();
});
jQuery(window).resize(function() {
listenWidth();
});
</script>
    </body>
</html>


According To Question:

#Change Div Position In Mobile
#How To Change Div Position In Responsive
#jQuery Change Order Of Divs
#Change Order Of Divs Responsive
#Div Order Change jQuery
#jQuery Change Column Order
#Javascript Reorder Divs
#Change Div Position By jQuery


Wednesday, 1 January 2020

How do I redirect to another webpage by jQuery?


There are many ways you can do page redirect to another webpage by jQuery.

Here I give you two example:
  1. Page redirect to another webpage on document ready by jQuery.
    <script>
    // Page redirect on document document
    jQuery(document).document( function() {
        // Similar behavior as an HTTP redirect
          window.location.replace("https://phpkishan.blogspot.com");  //OR
          window.location = "https://phpkishan.blogspot.com";  //OR
          window.location.href = "https://phpkishan.blogspot.com";  //OR
          window.location.assign("https://phpkishan.blogspot.com");
    }
    </script>

  2. Page redirect to another webpage on button clicking by jQuery.

    <button id="buttonID">Page redirect</button>

    <script>
    // Page redirect on button clicking
    jQuery(document).document( function() {
        jQuery( "#buttonID" ).click(function() {
            window.location.href = "https://phpkishan.blogspot.com/";
        });
    }
    </script>

Friday, 15 November 2019

How can I remove a particular value from an array in JavaScript with Example?


<!DOCTYPE html>
<html>  
<head>
    <title>How can I remove a particular value from an array in JavaScript with Example? -PHP Kishan</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" crossorigin="anonymous"></script>
    <script>  
    jQuery(document).ready(function(){
        orig_array = ['BattleGrounds', 'Fornite Battle Royale', 'League of Legends (LOL)', 'Counter-Strike: Global Offensive (CS: GO)', 'HearthStone', 'Minecraft', 'DOTA 2', 'Apex Legends', 'The Division 2', 'Splatoon 2', 'Rummy'];    //Ex: Game List
        document.getElementById("orig_array").innerHTML = orig_array;
      
      
        remove_game = orig_array.indexOf('Fornite Battle Royale'); // You can remove only one value (Game name)
        if (remove_game > -1) {
          orig_array.splice(remove_game, 1);
        }          
        document.getElementById("new_array").innerHTML = orig_array;
    });
    </script>
</head>
<body>
    <p><strong>Array Games List: </strong><br>=> <span id="orig_array"></span></p>  
    <p><strong>Reomve Game From List: </strong><br>=> Fornite Battle Royale</p>  
    <p><strong>New Array Games List: </strong><br>=> <span id="new_array"></span></p>  
</body>
</html>

Monday, 7 October 2019

How to redirect another webpage using JavaScript?



<!DOCTYPE html>
<html>   
<head>
    <title>How to redirect another webpage using JavaScript? -PHP Kishan</title>
    <script>   
        function new_Location(newurl) {       
            /* The wwindow.location method redirect to another webpage location. */
            window.location = newurl;
           
            // OR //
            /* The window.location.href() method redirect to another webpage location. */
            window.location.href = newurl;
           
            // OR //
            /* The window.location.assign() method loads a new location in the browser. */
            window.location.assign(newurl);
           
            // OR //
            /* The window.location.replace() method current location to redirect a new location in the browser. */
            window.location.replace(newurl);
        }

        var new_url = "https://phpkishan.blogspot.com/"; // Assigen New URL Location
    </script>
</head>
<body>
    <p>You can use any one method as per requirement for redirect your document location.</p>
    <input type="button" value="Redirect to new location" onclick="new_Location(new_url)">
</body>
</html>

Sunday, 19 May 2019

HTML to PDF Example






<!DOCTYPE html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>HTML to PDF Example - PHP Kishan</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js"></script>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
<style>
.center{text-align: center;}
.pdfdiv{background-color: #d9ec58;margin: 50px;padding:30px;}
.innerdiv{padding: 10px;margin: 15px 0;border: 2px solid #ea5555;}
.loader-div {position: fixed;top: 0;left: 0;width: 100%;height: 100%;background: rgba(0, 0, 0, 0.66);z-index: 9;bottom: 0;display: block;text-align:center;color: #fff;font-size: 22px;padding: 30% 0;}
.dp-img{border: 1px solid #e65959;border-radius: 50%;padding: 12px;margin: 6px;}
.btn-div{margin: 58px auto;}
.downloadpdf{text-align: center;background-color: #27d848;width: max-content;padding: 10px;border-radius: 10px;margin: 0 auto;font-size: 30px;text-decoration-line: none;}
.downloadpdf:hover{background-color: #d1d451;}
</style>
</head>
<body>
    <div class="btn-div center">
        <a class="downloadpdf" href="javascript:;" data-pdf="html2pdf" data-target="pdfdiv">Download PDF</a>
    </div>
    <div id="pdfdiv" class="pdfdiv center">
        <div class="innerdiv">
            <h1>This is a Heading</h1>
            <p>This is a paragraph.</p>
            <h5>This is a image.</h5>
            <div>
                <img class="dp-img" src="image.png" alt="HTML to PDF">
            </div>
        </div>
        <div class="innerdiv">
            <h1>This is a Heading</h1>
            <p>This is a paragraph.</p>
            <h5>This is a image.</h5>
            <div>
                <img class="dp-img" src="image.png" alt="HTML to PDF">
                <img class="dp-img" src="image.png" alt="HTML to PDF">
                <img class="dp-img" src="image.png" alt="HTML to PDF">
                <img class="dp-img" src="image.png" alt="HTML to PDF">
                <img class="dp-img" src="image.png" alt="HTML to PDF">
                <img class="dp-img" src="image.png" alt="HTML to PDF">
                <img class="dp-img" src="image.png" alt="HTML to PDF">
                <img class="dp-img" src="image.png" alt="HTML to PDF">
            </div>
        </div>
        <div class="innerdiv">
            <h1>This is a Heading</h1>
            <p>This is a paragraph.</p>
            <h5>This is a image.</h5>
            <div>
                <img class="dp-img" src="image.png" alt="HTML to PDF">
            </div>
        </div>       
    </div>
    <div class="btn-div center">
        <a class="downloadpdf" href="javascript:;" data-pdf="html2pdf" data-target="pdfdiv">Download PDF</a>
    </div>
    <div class="loader-div">Loading...</div>
<footer>
<script>
jQuery(document).ready(function(){
    jQuery('.loader-div').hide();
    jQuery(".downloadpdf").click(function(e){   
        jQuery('.loader-div').show();
        var pdfname = jQuery(this).data('pdf');
        var pdftarget = jQuery(this).data('target');
        console.log("PDF NAME:" + pdfname + "PDF HTML Div: " + pdftarget);   
       

        var pdfw = jQuery('#'+pdftarget).width();
        var pdfh = jQuery('#'+pdftarget).height();
        // console.log  ('div width: '+ pdfw + ' div height: '+pdfh);       

        html2canvas(document.getElementById(pdftarget)).then(function(canvas) {
            var imgData = canvas.toDataURL("image/jpeg");
            // console.log(imgData);
           
            var pdf = new jsPDF('','px',[pdfw,pdfh]);          
            var pwidth = pdf.internal.pageSize.getWidth();
            var pheight = pdf.internal.pageSize.getHeight();
            // console.log('PDF pwidth: '+ pwidth + ' PDF height: '+pheight);   

            pdf.addImage(imgData, 'JPEG', 0, 0, pwidth, pheight);                  
            pdf.save(pdfname+'.pdf');             
            jQuery('.loader-div').hide();
        }).catch(function(M) {
             console.log(M);   
        });
    });
});
</script>
</footer>
</body>
</html>

Note: All images of HTML page must be on the current domain.

Saturday, 29 December 2018

How to set default image on image loaded broken?



<!DOCTYPE html>
<html class="" lang="en-US">
<head>
<meta charset="UTF-8" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://unpkg.com/imagesloaded@4/imagesloaded.pkgd.min.js"></script>
<!-- or -->
<!-- <script src="https://unpkg.com/imagesloaded@4/imagesloaded.pkgd.js"></script> -->
<style type="text/css">.image-thumb {display: inline-block;margin: 10px;}</style>
</head>
<body>
<div id="product_div">
<div class="image-thumb"><img src="image/product_01.jpg" class="thumbnail-img" width="100" height="100"></div>
<div class="image-thumb"><img src="image/product_02.jpg" class="thumbnail-img" width="100" height="100"></div>
<div class="image-thumb"><img src="image/product_03.jpg" class="thumbnail-img" width="100" height="100"></div>
<div class="image-thumb"><img src="image/product_04.jpg" class="thumbnail-img" width="100" height="100"></div>
<div class="image-thumb"><img src="image/product_05.jpg" class="thumbnail-img" width="100" height="100"></div>
<div class="image-thumb"><img src="image/image/product_06.jpg" class="thumbnail-img" width="100" height="100"></div>
<div class="image-thumb"><img src="image/image/product_07.jpg" class="thumbnail-img" width="100" height="100"></div>
</div>

<script type="text/javascript">
jQuery(document).ready(function(){
if (jQuery('#product_div').length) {
jQuery('#product_div').imagesLoaded().always( function( instance ) {
console.log('all images loaded');
}).done( function( instance ) {
console.log('all images successfully loaded');
}).fail( function(instance2) {
console.log('all images loaded, at least one is broken');
}).progress( function( instance, image ) {
var result = image.isLoaded ? 'loaded' : 'broken';
console.log( 'image is => ' + result + ' for ' + image.img.src );
if(result == 'broken'){
var default_images = ["default_01.jpg","default_02.jpg","default_03.jpg","default_04.jpg","default_05.jpg"];
var new_image_name = default_images[Math.floor(Math.random()*default_images.length)];
console.log("default image is" + new_image_name); /* Random image select */
var default_img = 'default_images/' + new_image_name;
image.img.src = default_img;
}
});
}
});
</script>
</body>
</html>

Friday, 24 June 2016

How to add external link in target and class

<head>
    <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script type='text/javascript'>
$( document ).ready(function() {

  $('a').filter(function() {
  return this.hostname && this.hostname !== location.hostname;
}).attr('target', '_blank');

  $('a').filter(function() {
  return this.hostname && this.hostname !== location.hostname;
}).addClass("external");

});
    </script>
</head>

Tuesday, 5 April 2016

How to set div height dynamically?

Dynamically Assign Height | PHP Kishan

How to set div height dynamically?

PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language.
PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.
Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world.

Documentation

A good place to start is by skimming through the ever-growing list of frequently asked questions (with answers, of course). Then have a look at the rest of the online manual and other resources in the documentation section.

Mailing Lists

There are a number of mailing lists devoted to talking about PHP and related projects. This list describes them all, has links to searchable archives for all of the lists, and explains how to subscribe to the lists.

User Groups

Chances are that there is a User Group in your neighborhood, which are generally a great resource both for beginners and experienced PHP users. Check out the User Group listing on PHP.ug to see if there is one close by.

<!DOCTYPE html>
<html>
    <head>
  <style>
  #header_div,#bodycontent_div,#footer_div{
    border:1px solid #000;
    margin: 5px;
    padding: 10px;
    color: #000 !important;
  }
  #header_div{background-color:#E6FF00; text-align: center; }
  #bodycontent_div{background-color:#00FF6F; }
  #footer_div{background-color:#00D3FF; text-align: center; }
 

  </style>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
 </head>
 <body>
 <div>
  <div id="header_div">
  <h1>How to set div height dynamically?</h1>
   <p>PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language.</p>
   <p>PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.</p>
   <p>Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world.</p>
  </div>
  <div id="bodycontent_div" class="bodycontent_div">
   <h2>Documentation </h2>
   <p>A good place to start is by skimming through the ever-growing list of frequently asked questions (with answers, of course). Then have a look at the rest of the online manual and other resources in the documentation section.</p>

   <h3>Mailing Lists</h3>
   <p>There are a number of mailing lists devoted to talking about PHP and related projects. This list describes them all, has links to searchable archives for all of the lists, and explains how to subscribe to the lists.</p>
 
   <h4>User Groups</h4>
   <p>Chances are that there is a User Group in your neighborhood, which are generally a great resource both for beginners and experienced PHP users. Check out the User Group listing on PHP.ug to see if there is one close by.</p>

  </div>
  <div id="footer_div">
   <div> MySQL is the most popular database system used with PHP.</div>
 
  </div>
 </div>
 </body>
 <script>
 function assign_body_height(){
 //Dynamically assign height (Only for PC)
   var nav_header = $("#header_div").height();
   var nav_bodycontent = $("#bodycontent_div").height();
   var nav_footer = $("#footer_div").height();
   var screen_height =   window.innerHeight|| document.documentElement.clientHeight || document.body.clientHeight;
 
 
   if((nav_header + nav_bodycontent + nav_footer + 95) < screen_height)
   {
    //alert(screen_height);
    var newHeight = screen_height - (nav_header +  nav_footer + 95) + "px";    
    $(".bodycontent_div").css("height", newHeight);
   }
   else{
    //alert("more height");
    var newHeight = "auto";    
    jQuery(".bodycontent_div").css("height", newHeight);    
   
   }
 
 }

 $(document).ready( function()
 {  
  assign_body_height();
 
 });
 </script>
</html>

Monday, 14 March 2016

Set Equal Height Div Rows

Set Equal Height Div Rows
Equal Height
Equal Height
Equal Height
Equal Height
Equal Height
Equal Height
Equal Height
Equal Height
Equal Height
Equal Height
Equal Height
Equal Height
Equal Height
Equal Height
Equal Height
Equal Height
Equal Height
Equal Height

<html>
<head>
<style>
* {
    box-sizing: border-box;
}
body {
    background: -webkit-linear-gradient(top, #eee, rgba(222,112,6,0.2), #de7006),url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zd…N0eWxlPSdmaWxsOiNlMDg3Mjg7ZmlsdGVyOnVybCgjZmlsdGVyMzExNSknIC8+Cjwvc3ZnPg==);
    background: linear-gradient(to bottom, #eee, rgba(222,112,6,0.2), #de7006),url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zd…N0eWxlPSdmaWxsOiNlMDg3Mjg7ZmlsdGVyOnVybCgjZmlsdGVyMzExNSknIC8+Cjwvc3ZnPg==);
    overflow-x: hidden;
}

.blocks {
    float: left;
    width: 100%;
}
.block {
    float: left;
    width: 20%;
    background: #ffa;
    padding: 10px;
    margin: 10px;
text-align:center;
color:#000 !important;

}
</style>
<script type="text/javascript">
function heightsEqualizer(selector) {
    var elements = document.querySelectorAll(selector),
        max_height = 0,
        len = 0,
        i;

    if ( (elements) && (elements.length > 0) ) {
        len = elements.length;

        for (i = 0; i < len; i++) { // get max height
elements[i].style.height = ''; // reset height attr
            if (elements[i].clientHeight > max_height) {
                max_height = elements[i].clientHeight;
            }
        }

        for (i = 0; i < len; i++) { // set max height to all elements
            elements[i].style.height = max_height + 'px';
        }
    }
}

if (document.addEventListener) {
    document.addEventListener('DOMContentLoaded', function() {
        heightsEqualizer('.js-equal-height');
    });
window.addEventListener('resize', function(){
heightsEqualizer('.js-equal-height');
});
}

setTimeout(function () { // set 1 second timeout for having all fonts loaded
heightsEqualizer('.js-equal-height');
}, 1000);
</script>
</head>
<body>
<div class="blocks">
<div class="block js-equal-height">
Equal Height<br />
Equal Height<br />
</div>
<div class="block js-equal-height">
Equal Height<br />
Equal Height<br />
Equal Height<br />
Equal Height<br />
Equal Height<br />
Equal Height<br />
Equal Height<br />
Equal Height<br />
</div>
<div class="block js-equal-height">
Equal Height<br />
Equal Height<br />
Equal Height<br />
</div>
<div class="block js-equal-height">
Equal Height<br />
Equal Height<br />
Equal Height<br />
Equal Height<br />
Equal Height<br />
</div>
</div>
</body>
</html>

Wednesday, 9 March 2016

Card Flip In HTML

Card Flip In HTML
K
K

<html>
<head>
<style>
/*Card Flip*/

.card-container {
  width: 150px;
  height: 150px;
  position: relative;
  border: 1px solid #ccc;
  -webkit-perspective: 800px;
  -moz-perspective: 800px;
  -o-perspective: 800px;
  perspective: 800px;
  float: left;
  margin: 50px 50px 50px 50px;
  cursor: pointer;
}
.card {
  width: 100%;
  height: 100%;
  position: absolute;
  -webkit-transition: -webkit-transform 1s;
  -moz-transition: -moz-transform 1s;
  -o-transition: -o-transform 1s;
  transition: transform 1s;
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  -o-transform-style: preserve-3d;
  transform-style: preserve-3d;
  -webkit-transform-origin: 50% 50%;
}
.card div {
  display: block;
  height: 100%;
  width: 100%;
  line-height: 150px;
  color: white;
  text-align: center;
  font-weight: bold;
  font-size: 140px;
  position: absolute;
  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  -o-backface-visibility: hidden;
  backface-visibility: hidden;
}
.card .front {
  background: #FFE202;
}
.card .back {
  background: red;
  -webkit-transform: rotateY(180deg);
  -moz-transform: rotateY(180deg);
  -o-transform: rotateY(180deg);
  transform: rotateY(180deg);
}
.flipped {
  -webkit-transform: rotateY(180deg);
  -moz-transform: rotateY(180deg);
  -o-transform: rotateY(180deg);
  transform: rotateY(180deg);
}
.card:hover {
  -webkit-transform: rotateY(180deg);
  -moz-transform: rotateY(180deg);
  -o-transform: rotateY(180deg);
  transform: rotateY(180deg);
}
.flipped:hover {
  -webkit-transform: rotateY(-0deg);
  -moz-transform: rotateY(-0deg);
  -o-transform: rotateY(-0deg);
  transform: rotateY(-0deg);
}
/*Card Flip*/
</style>

</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<section class="card-container">
  <div class="card" id="card1">
    <div class="front">K</div>
    <div class="back">R</div>
  </div>
</section>
</body>
<script>
jQuery(".card").click(function() {
  var id = jQuery(this).attr('id');
  jQuery('#' + id).toggleClass('flipped');
});
</script>
</html>

HTML to Image

Display:
The tiger is the largest member of the felid (cat) family.

Canvas:

Image:

Download this Script Click Here

Monday, 7 December 2015

HTML Page Title Marquee

<!-- Add the event loader to the body tag as below -->
<title> Marquee Use in HTML Page Title</title>

<body onLoad="scrlsts()">
<h1>TITLE MARQUEE</h1>
<h2> Marquee Use in HTML page title</h2>
</body>

<!-- Add the script to the HEAD of your document -->
<script LANGUAGE="JavaScript">
//alert(document.title);
<!-- Begin
var scrl = document.title+" ";

function scrlsts() {
 scrl = scrl.substring(1, scrl.length) + scrl.substring(0, 1);
 document.title = scrl;
 setTimeout("scrlsts()", 300);
 }
//  End -->
</script>

Thursday, 3 December 2015

Remove  Characters in HTML

Thread: PHP - includes ( characters)

Try putting this after your <head> tag:

Code:
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

Tuesday, 3 November 2015

Family Tree In PHP

Create Family Tree In PHP


1st Step : Create these belove file and database
  - CSS : style.css, ddsmoothmenu.css, ddsmoothmenu-v.css
  - JS : ddsmoothmenu.js
  - HTML : tree.html
  - PHP   : index.php, add_member.php, data.php, update.php
       - Database Import : family_tree.sql


Download this Script Click Here