troubleshooting Question

variable contains id name, how to select based on variable name

Avatar of Brad Bansner
Brad Bansner asked on
jQueryJavaScript
4 Comments2 Solutions308 ViewsLast Modified:
The variable "value" has the name of an ID (build that in line 1). Lines 2 and 3 are attempting to do things to objects with the ID of what the variable contains. But I get an error:

$('#'+value).attr('id').addClass is not a function
var value=$(this).attr('id').replace('dir_', 'day_');
$('#'+value).attr('id').addClass('dayblockhl');
$('#'+value).attr('id').children('.gr_mwc_monthblockarrow').addClass('gr_mwc_monthblockarrowhl');

Open in new window

ASKER CERTIFIED SOLUTION
jrm213jrm213

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros