Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Dear Experts,

In my project i have used .html() function to copy some html contents.

But When i passed the Id to .html() function dynamically then it is not working...

Please see the JsFiddle

Please help me to solve this..

Thanks

Dileep
Posted
Updated 6-Jun-13 19:38pm
v2
Comments
Manfred Rudolf Bihy 7-Jun-13 4:48am    
Please also add the code you stored in JSFiddle to your question. Without seeing the code here most people won't be willing to help you.

Thanks you! :)

The problem is that you introduced single quotes around the identifier. They are not needed. See the corrected code below as it does exactly what you want:

JavaScript
var _UCID = 'ef6a5118-5282-4930-bb21-4f825da20840'
var UID = "#" + _UCID;

alert(UID);
alert($(UID).html());


Regards,

— Manfred
 
Share this answer
 
Comments
Nandakishore G N 7-Jun-13 5:23am    
write Manfred. My 5
C#
var _UCID = 'ef6a5118-5282-4930-bb21-4f825da20840';

var html = $('#' + _UCID).html();
alert(html);


Preppend '#' when you use Id selector of jQuery.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900