Created
January 16, 2018 08:40
-
-
Save jagroop/6b87a62a9ec2c0c5de1ac9a16e6d70f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
</head> | |
<body> | |
<input type="text" id="sample-text" value="Lorem ipsum dolor sit amet"> | |
<input type="checkbox" id="cb"> | |
<p id="result"></p> | |
<script> | |
$(document).ready(function(){ | |
$('#cb').change(function(e){ | |
e.preventDefault(); | |
var str = $('#sample-text').val(function(i, t) { return t.substr(0, 4); }); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment