添加到innerHTML正确的语法 [英] Adding to innerHTML correct syntax

查看:93
本文介绍了添加到innerHTML正确的语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想使用innerHTML向元素添加内容,正确的语法是什么? 以下是我无法正常工作的示例:

What is the correct syntax if I want to add content to an element using innerHTML. Below is my non working example:

   openNewWindow: function(content) {
popupWin = window.open(content,
    'open_window',
    'menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=640, height=480, left=0, top=0')
},

for (var index in mv.exifImages) {
        ele.innerHTML += "<p onclick = openNewWindow(mv.exifImages[index]> image" + index + "</p>";
    }

推荐答案

我认为是.变量index具有局部范围

i think it is. variable index has local scope

for (var index in mv.exifImages) {
        ele.innerHTML += "<p onclick = 'openNewWindow(\"" + mv.exifImages[index] + "\")'> image" + index + "</p>";
    }

这篇关于添加到innerHTML正确的语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆