random int between

Math.floor((Math.random() * 100) + 1);

Tags: 

set get value from input field

getvar bla = $('#txt_name').val();

set$('#txt_name').val('bla’);

Tags: 

html 5 input minimum length text

<input pattern=".{3,}" required title="3 characters minimum”]]>

Tags: 

click jquery add target

click

html

Click here

js

$( "#target" ).click(function() {

alert( "Handler for .click() called." );

});

Tags: 

on document load jquery

$( document ).ready(function() {

console.log( "ready!" );

});

Tags: 

on mouse down register x y

var clicking = false;

$('.selector').mousedown(function(){
clicking = true;
$('.clickstatus').text('mousedown');
});

$(document).mouseup(function(){
clicking = false;
$('.clickstatus').text('mouseup');
$('.movestatus').text('click released, no more move event');
})

$('.selector').mousemove(function(){
if(clicking == false) return;

// Mouse click + moving logic here
$('.movestatus').text('mouse moving');
});

Tags: 

Pages

Subscribe to hjsnips RSS