skip to Main Content

i wanna add a new div,created with js, to the html file.I use cpanel as storage.

html

<div class="row onerow"></div>

js

 $( "<div></div>" ).appendTo( ".onerow").addClass("col")

I wanna save that new div i just created on the html body.Right now the div is deleted on page refresh.

Full story: I have to create a website that contains a one row gallery.I wanna create a script where the admin can upload a photo and that photo will join the row as a new col.Upload is ready,but now i have to figure how to save the col to html body.Thank you for your time!

2

Answers


  1. You need to fix the attribute class enclosed with ":

    <div class="row onerow"></div>
    
    Login or Signup to reply.
  2. First of all you have a little html error.

    You should change your div as below

    <div class="row onerow"></div>
    

    and your jQuery code:

    $(document).ready(function() {
      $('.onerow')
        .append('<div>new div</div>')
        addClass('abc');
    });
    

    And here is a demo for your case https://jsfiddle.net/gfLajh07/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search