nextstopsun nextstopsun - 2 years ago 137
HTML Question

Get value of input element in event listener with d3

I have two html elements:

<input id="searchInput">
<div id="searchText"></div>

I'm using d3 to add a listener in a script."#searchInput").on("keyup",getSearchText);

I need a function that prints a value of input to a div

function getSearchText(value) {"#searchResults").html(value.toString());

But I don't know how to pass input value parameter to a listener function.

Answer Source

Try using an instance of this to get the value:"#searchResults").html(this.value);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download