Revised: I have a list items on the page that I'm creating from database records (messages). Each record contains an Id value that I'm currently putting into each individual message. What I'd like to do is when they click on a view link to grab the message's Id value so that I can then manipulate it with javascript.
Generated html looks like:
<div id"messages">
<div class="message">
A cool message <a href="/Message/View/1" id="message_1" class="viewMessage">View</a>
</div>
<div class="message">
A cool message <a href="/Message/View/2" id="message_2" class="viewMessage">View</a>
</div>
<div class="message">
A cool message <a href="/Message/View/3" id="message_3" class="viewMessage">View</a>
</div>
<div class="message">
A cool message <a href="/Message/View/4" id="message_4" class="viewMessage">View</a>
</div>
</div>
When I click on id=message_1 I want to get the id value of 1. I'm trying to avoid string manipulation in order to get the id value: like get the value after a '_'. It would be great if I could use a single attribute with the value '1' in it.
$('.viewMessage').click(function() {
...$(this).messageId...
});
Can I just make an attribute up? I'll actually try this too, but am thinking about the whole xhtml strict stuff so was thinking there's something better than doing that.