0

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?

3
  • 1
    don't want to use jquery??? Commented Sep 15, 2014 at 8:55
  • 1
    Yes, I don't. Do I have to use jquery to solve it? Commented Sep 15, 2014 at 8:57
  • 1
    you can use element.getAttribute(attributename) to get the value of an attribute without jQuery Commented Sep 15, 2014 at 8:59

1 Answer 1

1

this should help:

var itemId = document.getElementsByName('check')[0].getAttribute('itemId');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.