Is there any program or library to convert html to dom mainpulation script? [closed]

StackOverflow https://stackoverflow.com/questions/21423437

سؤال

I don't like using innerHTML, even it's faster.

But, I need to convert html to dom manipulation code.

Ex)

<div class="my-class">
    <a href="#my-link">My Link</a>
</div>

to

var div = document.createElement('div');
div.className = 'my-class';

var a = document.createElement('a');
a.href = '#my-link';
a.appendChild(document.createTextNode('My Link'));
div.appendChild(a)

------ EDIT

I can't use jQuery because of mobile (especially android)

هل كانت مفيدة؟

المحلول

Based on your comments,

it seems you're seeking template framework (eg: check handlebars.js) But it is entirely different where your output will be different.

Here is a list Template-Engine-Chooser!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top