Anil Kocabiyik
Anil Kocabiyik

Reputation: 1188

How can I get checkbox attribute with using javascript?

I' m using MVC and set an itemId attribute to checkboxes.

@Html.CheckBox("check", false, new { itemId = item.ID  })

Now I want to get this attribute with using javascipt but I could not.

I got the checkboxes list with this code:

var checkboxes = document.getElementsByName('check');

Are there any solution for it?

Upvotes: 0

Views: 79

Answers (1)

aleha_84
aleha_84

Reputation: 8539

this should help:

var itemId = document.getElementsByName('check')[0].getAttribute('itemId');

Upvotes: 1

Related Questions