Javascript/Show More Content

Advertisement


Question
http://jsfiddle.net/burn123/w2gWy/
The first thing I would like to do to this is be able to insert html tags into the .main div like <section> or <div> so I can apply the css propery text-indent to the <section>. But if I try to add any sort of html tag, the script breaks, and I cant use it. Is there something wrong with the jquery to where this isn't possible?

Answer
Hi Cody,

Thanks for your question.

Creating and inserting HTML tags into the DOM using jQuery is as easy as this:

//create the element
var section = $('<section></section>');
//add it to the DOM
$('body').append(section);

Here is a JSFiddle Example:

http://jsfiddle.net/6mPaG/

Best Wishes,

Kevin Chisholm

http://kevinchisholm.com/

http://blog.kevinchisholm.com/

Javascript

All Answers


Ask Experts

Volunteer


Kevin Chisholm

Expertise

I can answer questions about: JavaScript, Object-Oriented JavaScipt, JSON, AJAX, jQuery, HTML, CSS

Experience

I am a Front-End Web Developer living in New York City. I have provided services to titles such as Time.com, TimeForKids.com, SportIllustrated.com, coastalliving.com, People.com, TDAmeritrade.com, and Instyle.com. Being particularly passionate about Object-Oriented JavaScript as well as Web Standards, I spend a fair amount of time writing about / teaching Front-End Web Development techniques. In my free time I enjoy reading about advanced JavaScript, as well as Web Development trends and best practices. My Blog is: http://blog.kevinchisholm.com/ JavaScript-specific blog posts can be found here: http://blog.kevinchisholm.com/category/javascript/

Organizations
NYC Front-end Developers CSS3 / HTML5 The future of front end Front-End Engineers Javascript Syracuse University Alumni Network

Education/Credentials
Syracuse University - VPA - 1983 - 1987

Past/Present Clients
cookingchanneltv.com foodnetwork.com food.com hgtv.com diynetwork.com gactv.com frontdoor.com hgtvremodels.com travelchannel.com Time.com TimeForKids.com SportIllustrated.com coastalliving.com People.com TDAmeritrade.com ramirezco.com njsga.org soccercoliseum.com superdomesports.com afeenj.org

©2016 About.com. All rights reserved.