1

I need to dynamically designate some <button>s as having a value like correct=true or correct=false. I see how to use Ideally this attribute would be invisible to the a user clicking 'view source.' I can live with the answer being visible via a JavaScript debugger.

Right now I am storing it in a separate data structure and looking it up via the id which is dynamically constructed by AngularJS:

<div style="padding-top: 5px" class="col-md-offset-3" ng-repeat="answer in answers">
   <button id="answerChoice_{{$index}}" 
           style="font-size: 18px;" 
           class="btn btn-default" 
           ng-click="selectButton($event)" >

           {{answer}}

   </button>
</div>
1
  • 1
    Have you considered HTML 5 data- attributes? Commented Oct 21, 2013 at 19:02

1 Answer 1

2

ng comes with jquery light version so you can script something like

$('button').attr("correct",true);
Sign up to request clarification or add additional context in comments.

1 Comment

When I add required attr, the form is not being validated as required. Only when I write it by hand the required validation is fired.

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.