Your code isn't syntactically valid: the selector string is not delimited by quotes.
copy: $('text#description').text()
Your selector is also invalid. It's trying to select a <text>
element, when you should be selecting an <input>
element. Since you've got an ID already, there's no reason to write a more-specific selector, anyway.
copy: $('#description').text()
You also need to get the text to copy when the button is clicked, not when the page loads.
copy: function() {
return $('#description').text();
}
But we're dealing with a form input field, so use .val()
instead of .text()
:
copy: function() {
return $('#description').val();
}
and lastly, you need to set up the fiddle correctly.
Here's a working demo: http://jsfiddle.net/mattball/kqKTG