I'm using backbone. In my template I have ----
<a href="#" id='<%= member.get("person").id%>'><%= member.get('person').name%></a>
The id is dynamically set. I need to use the id as a variable to make a JSON call.
I've tried a few things -
$('a').click(function(){
var memberId = $(this).attr("id");
console.log(memberId);
})
or
$('a').click(function(){
var ID = this.attr('id');
console.log();
})
and a couple other variations.
Suggestions?
Thanks for all the responses.
I should have mentioned that I was trying these things in the document ready just to see if it would work. My bad, this is my first post on here. Ultimately, the function should be in my view (I think). So it should look more like this -
memberId: function(event){
$(this).attr('id');
}
Which, again is not working.....