5 Replies - 641 Views - Last Post: 28 December 2014 - 08:21 AM

#1 Astro52a9   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 87
  • Joined: 24-March 13

replace div with simple jquery

Posted 27 December 2014 - 10:55 PM

i would like to be able to replace my div within each other but it s not working cant figure out why

here is a the jsfiddle DEMO
Is This A Good Question/Topic? 0
  • +

Replies To: replace div with simple jquery

#2 laytonsdad   User is offline

  • I identify as an attack helicopter!
  • member icon

Reputation: 467
  • View blog
  • Posts: 1,998
  • Joined: 30-April 10

Re: replace div with simple jquery

Posted 28 December 2014 - 01:06 AM

Your demo doesn't have jquery attached at all.
Was This Post Helpful? 0
  • +
  • -

#3 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5612
  • View blog
  • Posts: 14,686
  • Joined: 18-April 07

Re: replace div with simple jquery

Posted 28 December 2014 - 01:10 AM

Few things... in the fiddle you have to make sure to specify jQuery as a library you are using. Secondly, you had your id=4 INSIDE the string for the class. Third with replaceWith you have to make sure you select the element that you are going to replace with. Lastly, you have to make sure the page loads fully before running code so you should wrap your code inside a document.ready event (or self executing function).

I have made these corrections and saved it as a fiddle...

http://jsfiddle.net/aeyg89rd/2/

Hope you get what I am saying. :)
Was This Post Helpful? 1
  • +
  • -

#4 Blindman67   User is offline

  • D.I.C Addict
  • member icon

Reputation: 140
  • View blog
  • Posts: 620
  • Joined: 15-March 14

Re: replace div with simple jquery

Posted 28 December 2014 - 01:36 AM

I Don't use JQuery but I dont think it will let you have two elements with the same id.
Was This Post Helpful? 0
  • +
  • -

#5 Astro52a9   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 87
  • Joined: 24-March 13

Re: replace div with simple jquery

Posted 28 December 2014 - 07:04 AM

Thanks , exactly what i was looking for
Was This Post Helpful? 0
  • +
  • -

#6 astonecipher   User is offline

  • Enterprise Software Architect
  • member icon

Reputation: 3215
  • View blog
  • Posts: 12,098
  • Joined: 03-December 12

Re: replace div with simple jquery

Posted 28 December 2014 - 08:21 AM

I don't know why you down reped Laytonsdad, he made a valid statement. You can't use jQuery if the library isn't specified.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1