<div class="status">
<span class="bar"></span>
<div class="ep">Ep 12</div>
</div>
I want to add another div like "ep" div in span with class "dub" with javascript or Jquery
<div class="status">
<span class="bar"></span>
<div class="ep">Ep 12</div>
</div>
I want to add another div like "ep" div in span with class "dub" with javascript or Jquery
I think you can easily find the answer by search it on internet .
There are many ways to do this. But I do it with the easiest way. Give your span a id because changes we done to the class will affect all it’s members. So I give ep_bar as id.
<div class="status">
<span class="bar" id=”ep_bar”></span>
<div class="ep">Ep 12</div>
</div>
Then import jquery. After that,
Var div1 = '<div class="ep">Ep 13</div>'
$(“#ep_bar”).append(div1);
<code>
var $div = $("<div />");
$div.addClass("ep").html("Ep 12");
var $span = $("<span />");
$span.addClass("dub");
$div.appendTo($span);
</code>
And then append your span wherever you need
var newDiv = document.createElement('div');
newDiv.classList.add('class-name');
document.getElementsByClassName('bar')[0].append(newDiv);