html标签的class属性里面怎么嵌入变量

        var id = snapshot.val().id;

        var content = snapshot.val().content;

        var textObj = '<div class="task-item">\

                        <input type="checkbox" />\

                        <span class="ui-icon ui-icon-clock"></span>\

                        <span class="task-content">'+content+'</span>\

                        <span class="task-detail">&nbspdetail</span>\

                        </div>';

我想把第一行的id变量(是一个数字)加到第三行div标签的class属性里面,可以直接嵌进去吗?

天涯尽头无女友
浏览 1254回答 1
1回答

阿波罗的战车

&nbsp; &nbsp; var id = snapshot.val().id;&nbsp; &nbsp; var content = snapshot.val().content;&nbsp; &nbsp; var textObj = '<div class="task-item'+id+'">\&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <input type="checkbox" />\&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="ui-icon ui-icon-clock"></span>\&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="task-content">'+content+'</span>\&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="task-detail">&nbspdetail</span>\&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>';
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript