0

I wan to create a html tag: <div ng-app></div>, I try to use document.createElement('div') to create the div tag, but I don't know how to add ng-app to the div tag.

The function element.setAttribute(key, value) doesn't fit my flavor here.

1
  • Why element.setAttribute(key, value) function doesn't fit your flavor? Commented Jul 13, 2015 at 4:42

1 Answer 1

1

Just pass an empty string as the second parameter for setAttribute.

var div = document.getElementsByTagName('div')[0];
div.setAttribute('ng-app','');
<div>Testing</div>

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.