java - How to get HTML element properties on placing the cursor over it? -
is there way can properties of element on place cursor on? using javafx browser load websites. cannot use firebug or plugins. there possibility achieve this? please help. inspect element in firebug.
in javascript, when "choose element" mode activated, can attach mouseover
handler document. receive repeated calls mouse moves on elements. can tell element mouse on via target
property on event
object, e.g.:
document.addeventlistener("mouseover", function(e) { // use e.target know element }, false);
then @ element. might hook mouseout
know when leave element.
there limits this. instance, can't list of event handlers attached through normal dom api.
here's simple example demonstrating handler:
var lastelement = null; var display = document.getelementbyid("display"); document.addeventlistener("mouseover", function(e) { if (e.target != lastelement) { lastelement = e.target; show("tag", lastelement.tagname); show("id", lastelement.id); show("name", lastelement.name); show("class", lastelement.classname); show("style-color", lastelement.style.color); show("computed-color", getcomputedstyle(lastelement).color); } }, false); document.addeventlistener("mouseout", function(e) { var n, list; if (e.target == lastelement) { list = display.queryselector("span"); (n = 0; n < list.length; ++n) { list[n].innerhtml = ""; } lastelement = null; } }, false); function show(type, text) { display.queryselector("." + type).innerhtml = text; }
.foo { color: green; }
<p id="main-paragraph"> test, <strong class="foo">various elements</strong> can <em style="color: blue">mouse over</em>. <input type="text" name="the-input"> </p> <div id="display"> <div>tag: <span class="tag"></span></div> <div>id: <span class="id"></span></div> <div>name: <span class="name"></span></div> <div>class: <span class="class"></span></div> <div>style.color: <span class="style-color"></span></div> <div>computedstyle.color: <span class="computed-color"></span></div> </div>
Comments
Post a Comment