Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在 JavaFX WebView 中设置 div 的类属性,如下所示:
Element div = webView.getEngine().getDocument().createElement("div"); div.setAttribute("class", "myCssClass"); //append div to body...
但是,像这样设置div的class属性似乎没有任何效果。有什么我想念的吗?我还尝试了“className”作为属性名称。
谢谢!
找到了一个(或)解决方案:
HTMLElement div = (HTMLElement) webView.getEngine().getDocument().createElement("div"); div.setClassName("myCssClass");