-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

1
  • 2
    good . go for it. who stops you? Commented Mar 20, 2018 at 20:05

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

-2
var newDiv = document.createElement('div');

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

document.getElementsByClassName('bar')[0].append(newDiv);

4 Comments

tnx, but in the div i want to add text like the example Ep 12
@ChamsAgouni Then you would add newDiv.textContent = 'Ep 12'
@ChamsAgouni If that worked for you I'd appreciate it if you'd accept my answer.
it worked but i got a new problem

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.