Relativity: Copy to Clipboard
I just started learning javascript and jQuery today so please bear with me ^^
- <html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.copy.js"></script>
<script language='Javascript'>
$(document).ready(function()
{
$("p").click(function()
{
$.copy($("p").text());
});
});
</script>
</head>
<body>
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
</body>
</html>
The desired outcome for the code above is to make it so that any number that is clicked is copied to the computers clipboard for easy pasting. However, in the example above, if I click on any of the numbers, 12345 is copied.
Is there anyway that I can take that click function and turn it into a relative function that changes based on what was clicked? I've looked at some code using .this which seems to be what I'll need to do, but I can't, for the life of me, figure it out. Another way I thought of solving this would be to give each <p> a unique ID, but that will be annoying if it's used a lot.
The plugin I'm using can be found here:
http://yangshuai.googlepages.com/jquerycopypluginThanks a lot! :)
John