javascript - My element foreignObject is not shown -


i'm trying add foreignobject inside of svg, not shown. added inside svg. why happen, , how can fix it?

 body = d3.select('body')  svg = body.append('svg').attr('height', 600).attr('width', 600)        var div= svg.append('foreignobject')  .attr("width",50)  .attr('height',50)  .append("div")  .attr("class", "tooltip")  .style("opacity", 1);   div.append('img')  .attr("id", "img_tweet").attr("src", "")  .attr("class", "imagen_tweet");  div.append('div').attr("id", "texto_tweet");  document.getelementbyid('img_tweet').src="https://www.amrita.edu/sites/default/files/news-images/new/news-events/images/l-nov/grass.jpg"; document.getelementbyid('texto_tweet').innerhtml='message' 

https://jsfiddle.net/tzp3oe5a/

you have prefix outer html xhtml .append("xhtml:div") can read more explanation here using foreignobject add svg dynamically using d3js

     body = d3.select('body')       svg = body.append('svg').attr('height', 600).attr('width', 600)                   var div= svg.append('foreignobject')       	.attr("width", 50)      	.attr("height", 50)       .append("xhtml:div")       .attr("class", "tooltip")       .style("opacity", 1);        div.append('img')       .attr("id", "img_tweet").attr("src", "https://www.amrita.edu/sites/default/files/news-images/new/news-events/images/l-nov/grass.jpg")       .attr("class", "imagen_tweet");       div.append('div').attr("id", "texto_tweet");             //document.getelementbyid('img_tweet').src="https://www.amrita.edu/sites/default/files/news-images/new/news-events/images/l-nov/grass.jpg";      document.getelementbyid('texto_tweet').innerhtml='message'
      div.tooltip {          position: absolute;          top:14px;          left: 62px;          text-align: center;          width: 100px;          height: 40px;          padding: 2px;          font: 12px sans-serif;          background: white;          border-radius: 8px;          pointer-events: none;          z-index: 999999;        }          .imagen_tweet{          width: 20px;          height: 20px;        }
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.js"></script>

working jsfiddle https://jsfiddle.net/azs06/tzp3oe5a/2/


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -