I have a Sencha Touch application, and I want to create and append to the DOM dynamically for some custom HTML panels.
I really want to be able to do this:
$('<div><p>Stuff</p></div>')[0]
to create DOM elements, but I can't find any such alternative in ExtJS. Does this sort of "create this big snippet" syntax exist in ExtJS, or is there a smaller library alternative that doesn't require that I pull in all of jQuery?
It also feels a little silly to mix two major frameworks.
You can just do it the same way that jQuery does it ; create an element and set the innerHTML
property to the HTML code, and get the children of the element:
var e = document.createElement('DIV');
e.innerHTML = '<div><p>Stuff</p></div>';
var div = e.childNodes[0];
You should just use jQuery. It's not that big.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.