Reputation: 4122
In my cshtml view, If I have:
foreach (var x in mycollection)
{
<li id="a + @x.id"></li>
}
If you look how i'm setting this id, I'm assigning 'a' plus the id so a1, or a2, or a3, ect...to give each element separate id's. Hoever this isn't working for me when I go to use it in jquery:
function(id) {
$('#a' + id).css({ "visibility": "hidden" });
}
I can't just use '@x.Id' because I'm already using that somewhere else. How can I make these id's custom? Thanks for any tips.
Upvotes: 0
Views: 313
Reputation: 388316
I think <li id="a + @x.id"></li>
should be <li id="[email protected]"></li>
and then $('#a-' + id)
.
Because <li id="a + @x.id"></li>
creates a element like <li id="a + 1"></li>
not <li id="a1"></li>
Upvotes: 1