how to add content to div in d3 js d3.select('body').append('div') after this steps

6.5k Views Asked by At

adding content to div in d3 js

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>'  

i want to add this content to

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

above content in that div is this possible,help me

2

There are 2 best solutions below

2
On

It's good to use jQuery for this. But, this will also work 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');
0
On

This is solution to find this by click

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

click