【问题标题】:how to add content to div in d3 js d3.select('body').append('div') after this steps在此步骤之后如何在 d3 js d3.select('body').append('div') 中将内容添加到 div
【发布时间】:2015-02-18 01:48:56
【问题描述】:

在 d3 js 中向 div 添加内容

gv_html='<span style="margin: 2px;background-color:#ffffff ;position:relative;height: 30px ">      <input ?onkeyup=search() id="setext" style="height:27px " type="text" >   <img  style="position: ?absolute;right:2px ;padding-top:3px " id="myI" src="search.jpg" > </span>'  

我想将此内容添加到

d3.select('body').append('div').add 

上面那个div的内容是不是可以的,帮帮我

【问题讨论】:

标签: javascript svg d3.js jquery-svg


【解决方案1】:

为此使用 jQuery 很好。但是,这也可以http://jsfiddle.net/39rwneLL/1/

d3.select('div')
.append('span')
.style('margin', '2px')
.style('background-color', '#ffffff')
.style('position', 'relative')
.style('height', '30px');
d3.select('span')
.append('input')
.attr('id', 'setext')
.attr('attr', 'text')
.style('height', '27px');
d3.select('span')
.append('img')
.attr('id', 'myI')
.attr('src','http://upload.wikimedia.org/wikipedia/en/8/89/Construction_Icon_small.png')
.style('height', '20px')
.style('position', 'absolute')
.style('right', '2px')
.style('padding-top', '3px');

【讨论】:

  • 它适用于 html div 标签,但我想在 svg 中添加这个元素,它不起作用 d3.select('svg').append('div').add
  • 你可以在这里找到你的分析器stackoverflow.com/questions/17595813/…
【解决方案2】:

这是通过点击找到它的解决方案

d3.select('#set1').append("input").attr("id","setText").attr("type","text").style("height","27px").on("keyup",search);

click

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-10
    • 1970-01-01
    • 2014-05-26
    • 1970-01-01
    • 1970-01-01
    • 2016-10-01
    • 2020-12-26
    相关资源
    最近更新 更多