Created
February 27, 2010 12:54
-
-
Save latentflip/316672 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<html> | |
<!-- http://docs.jquery.com/ --> | |
<head> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
// we will add our javascript code here | |
$(document).ready(function() { | |
//Tag cloud selection logic | |
$("#tag_cloud li").click(function() { | |
var tag_text = $(this).text(); | |
var box_text = $('#tags').val(); | |
//Check if already in textarea before appending | |
var position = box_text.indexOf(tag_text) | |
if (position == -1) { | |
if (box_text.length > 3) { | |
box_text = box_text+', '; | |
} | |
box_text = box_text+tag_text; | |
$('#tags').val(box_text); | |
} | |
return false; | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<!-- we will add our HTML content here --> | |
<h3>Tags</h3> | |
<p>small bug that once edited the jQuery stops pasting</p> | |
<textarea id="tags" cols=100 rows=4> </textarea> | |
<ul id="tag_cloud"> | |
<li>Programming</li> | |
<li>Ruby</li> | |
<li>Java</li> | |
</ul> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment