[英]applying data-bind dynamically using javascript
I edited HTML element in javascript: 我在javascript中编辑了HTML元素:
document.getElementsByClassName('newc')[0].innerHTML=document.getElementsByClassName('newc')[0].innerHTML+string;
now newc
class had a component binded
with it in html document. 现在
newc
类在html文档中具有与其binded
的组件。 But after inserting the extra html part i thought that new html part would bind the property itself, but it didn't. 但是在插入了额外的html部分之后,我认为新的html部分将绑定属性本身,但事实并非如此。 So i want to know how to implement
data-bind=""
dynamically through JavaScript. 所以我想知道如何通过JavaScript动态地实现
data-bind=""
。
JQuery: jQuery的:
$('.newc').data('bind', 'value_for_bind');
Javascript: Javascript:
document.getElementsByClassName('newc')[0].setAttribute("data-bind", "value_for_bind");
Hope this helps. 希望这可以帮助。
Regards 问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.