apurva patil
apurva patil

Reputation: 25

div inside .html() function of jquery for styling of content

I am trying to load the div content of one page with other content on click of a link.For that purpose I am using .click() function and .html() function which has all the content.This is working fine. But now I want the contents to be styled.So I am using divs inside the html() function to do so.But it is not working.The content is not getting displayed at all. The jQuery code is as follows..

$(".vision").click(function(){

    $("#rightcolumn").html("<div id="rightcol_h1">VISION</div>");
    });

rightcolumn is the div name that has to be changed. And rightcol_h1 is to style the heading. It is as follows..

    #rightcol_h1{
font-size: 16px;
font-family: Arial, Helvetica, sans-serif;
color: #00578C;
font-weight: bold;
}

When I do this nothing is getting displayed.What am I doing wrong.Is the way i have used div inside html() wrong?

Upvotes: 0

Views: 123

Answers (1)

adeneo
adeneo

Reputation: 318222

You've messed up the quotes, but a better way to create elements would be :

$(".vision").on('click', function(){
    var rightCol = $('<div />', {id: 'rightcol_h1', text: 'VISION'});
    $("#rightcolumn").html(rightCol);
});

Upvotes: 2

Related Questions