Skip to content

Instantly share code, notes, and snippets.

@jagroop jagroop/cb-test.html
Created Jan 16, 2018

Embed
What would you like to do?
<!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
You can’t perform that action at this time.