使用d3获取事件侦听器中输入元素的值 [英] Get value of input element in event listener with d3
本文介绍了使用d3获取事件侦听器中输入元素的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个html元素:
I have two html elements:
<input id="searchInput">
<div id="searchText"></div>
我使用d3在脚本中添加监听器。
I'm using d3 to add a listener in a script.
d3.select("#searchInput").on("keyup",getSearchText);
我需要一个将输入值输出到div的函数
I need a function that prints a value of input to a div
function getSearchText(value) {
d3.select("#searchResults").html(value.toString());
}
但我不知道如何将输入值参数传递给侦听器函数。
But I don't know how to pass input value parameter to a listener function.
推荐答案
尝试使用
的实例获取值:
Try using an instance of this
to get the value:
d3.select("#searchResults").html(this.value);
这篇关于使用d3获取事件侦听器中输入元素的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文