taosuzhan
taosuzhan
2017-09-20 01:57

js循环生成div div里面有p标签 点击事件怎么得到点击的p标签内的值

2
  • div
  • java
  • javascript
<script id="dataTemplate" type="text/html">
    {{# for(var i=0;i<useData.length;i++){ }} 
        <div class="weui-cell" onclick="details(this);>
        <div class="weui-cell__bd">
            <label>{{ useData[i].DATE_TIME }}</label>
        </div>
        <div class="weui-cell__ft">
            <p>{{ useData[i].DATA }} kWh</p>
        </div>
        </div>
    {{# }}}
</script>`

![图片说明](https://img-ask.csdn.net/upload/201709/20/1505872412_61407.png)


        function details(obj) {//断点显示obj="weui-cell";

alert(obj);//弹框显示   [object HTMLDivElement]

    }
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答