jQuery - Difficulty with copy-to-clipboard and a textbox

0 votes

I've found several scripts for copying a textbox value to the clipboard.

Here's the function I am using:

it to work is on a textbox in a form #project-entry-form--folder-location with a button to call the function #project-entry-form--folder-location-copy The textbox and button are there on page load, the VALUE of the textbox is generated as the user makes certain choices in the form.

THE FUNCTION IS FIRING... If I click the button, the message generated at the bottom of the copyToClipboard() function comes up. So, I know the click functionality is working and the function is firing. But, nothing is on the clipboard. For some reason it doesn't get any value for the element passed to it.

I can alert() the value of the textbox from within the same click event and that works. So, I know the textbox's value is accessible.

I cannot figure out why the function works fine given one input element, but not the other. Only difference is when the value is there. But, then the alert() function can get it just fine, why not the copyToClipboard() function? No different than the user typing into the textbox, right?

Jun 1, 2022 in JQuery by Edureka
• 13,640 points
261 views

1 answer to this question.

0 votes

I think the problem is with your "this" context.

Remember that the object which serves as the parameter to the editInPlace call is constructed before you make the call.  So you don't have an appropriate "this".

.attr("folder") will work fine, as you could test by, say,
 

  1.     $(".edit").click(function(evt) {
  2.         alert($(this).attr("folder"));
  3.     });
answered Jun 1, 2022 by Edureka
• 13,640 points

Related Questions In JQuery

0 votes
1 answer

How to get all css properties and events of a html element with jquery or other libraries?

You can get the computed value of ...READ MORE

answered Jun 14, 2022 in JQuery by gaurav
• 22,940 points
206 views
0 votes
1 answer

How do I pre-populate a jQuery Datepicker textbox with today's date?

Hello @kartik, You must FIRST call datepicker() > then use ...READ MORE

answered May 29, 2020 in JQuery by Niroj
• 82,820 points
7,686 views
0 votes
1 answer

How to scroll to element from bottom to top with a nice animation using Jquery?

Hello @kartik, Assuming you have a button with ...READ MORE

answered Sep 10, 2020 in JQuery by Niroj
• 82,820 points
3,041 views
0 votes
1 answer

How to find a parent with a known class in jQuery?

Hello @kartik, Assuming that this is .d, you can write $(this).closest('.a'); The closest method returns the ...READ MORE

answered Oct 5, 2020 in JQuery by Niroj
• 82,820 points
3,646 views
0 votes
1 answer

How to check a radio button with jQuery?

For versions of jQuery equal or above ...READ MORE

answered Jun 3, 2022 in JQuery by Edureka
• 13,640 points
175 views
0 votes
1 answer

How to check a radio button with jQuery?

“jquery datepicker format” Code Answer's $('#timePicker'). datetimepicker({ // dateFormat: ...READ MORE

answered Jun 10, 2022 in JQuery by gaurav
• 22,940 points
150 views
0 votes
1 answer

How to check a radio button with jQuery?

We can check the status of a ...READ MORE

answered Jun 10, 2022 in JQuery by rajatha
• 7,480 points
4,943 views
0 votes
1 answer

How to distinguish between left and right mouse click with jQuery

Using the mousedown() method: The mousedown() method in ...READ MORE

answered Jun 14, 2022 in JQuery by gaurav
• 22,940 points
120 views
0 votes
1 answer

How to make a simple modal pop up form using jquery and html?

Create A Modal <button onclick="document.getElementById('id01').style.display='block'" class="w3-button">Open Modal</button> ... <div ...READ MORE

answered Jun 2, 2022 in JQuery by Edureka
• 13,640 points
3,220 views
0 votes
1 answer

How to disable all <input > inside a form with jQuery?

To disable all form elements inside 'target', ...READ MORE

answered Jun 3, 2022 in JQuery by Edureka
• 13,640 points
460 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP