Getting Id value with # appended.
Somewhat of a beginner question but in searching around I cannot find an answer. In a situation where I am trying to retrieve a clicked objects id I would use the method below:
- $(this).attr("id");
However, the id value I am always getting back is lacking the # sign which I need to append like so:
- var id = "#" + $(this).attr("id");
Then I can utilize the id value. I understand I can just use $(this) to manipulate the object but in certain cases I'd just like the Id value.
Just curious and looking to clean my code up a bit. Thought about writing a method to extend the jQuery lib to do this but I figured I'd check before I try and reinvent the wheel.
Thanks.