javascript - How to append div tag into a SVG rect element? -


i couldn't find correct solution problem decided write new question.

i'm not sure possible hope is.

so here html browser provides. i'm copying "elements" tab in browser.

<svg width="960" height="728" style="margin-left: 0px;"> <g transform="translate(0,24)" style="shape-rendering: crispedges;">     <g class="depth">         <g>             <g>                 <rect class="child" x="0" y="0" width="960" height="704" style="fill: rgb(192, 192, 192);">1.1.1.                     <div class="jstree">                         <div>testcontent</div>                     </div>                 </rect>             </g>         </g>     </g> </g> 

(i'm creating js).

my problem i'm creating div inside rect tag, div , content doesn't appear on screen inside rectangle.

i want know if possible make appear , if how ?

unfortunately, it's not possible: cannot append html element svg element.

the way using div (or p, h1, li etc) in svg using foreignobject. in code, this:

<svg width="960" height="728" style="margin-left: 0px;">  <g transform="translate(0,24)" style="shape-rendering: crispedges;">      <g class="depth">          <g>              <g>                  <rect class="child" x="0" y="0" width="960" height="704" style="fill: rgb(192, 192, 192);">                  </rect>                  <foreignobject x="100" y="100" width="100" height="100">  		    <div xmlns="http://www.w3.org/1999/xhtml" class="jstree">                          <div>testcontent</div>                      </div>  	        </foreignobject>              </g>          </g>      </g>  </g>

notice foreignobject comes after rectangle, not inside (as in code). also, notice foreignobject not work in ie: https://developer.mozilla.org/en/docs/web/svg/element/foreignobject


Comments