milosev.com
  • Home
    • List all categories
    • Sitemap
  • Downloads
    • WebSphere
    • Hitachi902
    • Hospital
    • Kryptonite
    • OCR
    • APK
  • About me
    • Gallery
      • Italy2022
      • Côte d'Azur 2024
    • Curriculum vitae
      • Resume
      • Lebenslauf
    • Social networks
      • Facebook
      • Twitter
      • LinkedIn
      • Xing
      • GitHub
      • Google Maps
      • Sports tracker
    • Adventures planning
  1. You are here:  
  2. Home

jQuery animation

Details
Written by: Stanko Milosev
Category: jQuery
Published: 09 November 2015
Last Updated: 09 November 2015
Hits: 4278

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="/jquery-2.1.4.js" type="text/javascript"></script>
    <script src="/index.js" type="text/javascript" defer></script>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>

    <div class="animation" style="position: absolute">
        I am the text which is going to be animated
    </div>

</body>
</html>

JS:

/*global $*/

$(".animation").animate({
    left: "+=500"
}, 5000, function () {
    alert("finish!");
});

Taken from here.

Don't loose focus

Details
Written by: Stanko Milosev
Category: jQuery
Published: 23 February 2015
Last Updated: 24 February 2015
Hits: 4444

For example, if you want to have button which will clear content from text box, but you don't want to loose focus from your text box then you can use this code: 

<!DOCTYPE html>
<html>

	<head>
	</head>

	<body>

		<input type="text" placeholder="Your text" id="myText">
		<button>Test</button>
		
		<script type="text/javascript" src="/jquery-2.1.3.js"></script>
		<script type="text/javascript" src="/index.js"></script>

	</body>

</html>

JS:

$("#myText").focus(function (event) {
	alert("Focus!");
});

$("button").mousedown(function( event ) {
	event.preventDefault();
	$("#myText").val("");
});

Thing to notice:

event.preventDefault();

Example you can see here.

Or here:

How to check jQuery version

Details
Written by: Stanko Milosev
Category: jQuery
Published: 12 January 2015
Last Updated: 30 November -0001
Hits: 4381

In console write:

$.fn.jquery

From here.

Few event examples

Details
Written by: Stanko Milosev
Category: jQuery
Published: 09 October 2014
Last Updated: 09 October 2014
Hits: 4737

HTML:

<!DOCTYPE html>
<html>

	<head>
		<script type="text/javascript" src="/jquery-2.1.1.js"></script>
		<script type="text/javascript" src="/index.js"></script>
	</head>

	<body>
		<input class="myInput" placeholder="some text">
		<p/>
		<a class="myHref" href="http://www.milosev.com">Test</a>
		<div class="log"></div>
	</body>
	
</html>

JS:

window.onload = function() {
	$(".myInput").focusout(function() {
		$(".log").html($(".log").html() + " I am out of focus <br/>");
	});
	
	$(".myInput").focus(function() {
		$(".log").html($(".log").html() + " I am focused <br/>");
	});
	
	$(".myHref").mouseenter(function() {
		$(".log").html($(".log").html() + " Mouse enter <br/>");
	});
	
	$(".myHref").mouseleave(function() {
		$(".log").html($(".log").html() + " Mouse leave <br/>");
	});
	
	$(".myInput").change(function (handler) {
		$(".log").html($(".log").html() + "I am changed, and the value is: " + $(".myInput").val() + "<br/>")
	});	
	
	$(".myInput").keypress(function (handler) {
		$(".log").html($(".log").html() + "Key code: " +  handler.keyCode + "<br/>")
	});
	
	$(".myInput").on('input', $(".myInput"), function() {
		$(".log").html($(".log").html() + "Input called, and value is: " +  $(".myInput").val() + "<br/>")
	});	
}

Example download from here.

  1. Slider
  2. Change page in the middle of Ajax request
  3. Checking whether a click event was triggered by physically mouse clicking or not
  4. Do not select hidden type

Subcategories

C#

Azure

ASP.NET

JavaScript

Software Development Philosophy

MS SQL

IBM WebSphere MQ

MySQL

Joomla

Delphi

PHP

Windows

Life

Lazarus

Downloads

Android

CSS

Chrome

HTML

Linux

Eclipse

Page 63 of 164

  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67