JSFiddle - React, Tailwind, and code Playground

by SengKook Park

HTML

<div data-widgetName="menu">Select the genre</div>

JavaScript

var div = document.body.children[0]
// children 在IE中包含注释节点
if (div.nodeType != 1) {
  // 不能使用nextSibling, 因为有可能为空白节点
  div = document.body.children[1]  
}

alert(div.getAttribute('data-widgetName'))