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

Chams Agouni
  • 87
  • 11

3 Answers3

2

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);

Or else find another way/s here or here

dilusha_dasanayaka
  • 1,244
  • 2
  • 14
  • 28
0
<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

Ariel Haim
  • 86
  • 6
-2
var newDiv = document.createElement('div');

newDiv.classList.add('class-name');

document.getElementsByClassName('bar')[0].append(newDiv);
Anant Kumar Singh
  • 68,309
  • 10
  • 50
  • 94
David
  • 929
  • 1
  • 12
  • 18