S Raihan
S Raihan

Reputation: 387

How to take many HTML tag as a javascript variable

I have a variable with HTML and CSS value . How Can I add another HTML element inside a <span > element. Like if I want to take a <a> element inside a <span> element with different class?

var newSpan = $("<span></span>", {
    title: "Double Click to Edit Groups Name",
    id:     "myInstance2",
    style:"display:none; float:left;",
    text: "Unnamed Group",
    class: "title-span"
})

Upvotes: 1

Views: 75

Answers (1)

scrappedcola
scrappedcola

Reputation: 10572

You can append content to that element:

newSpan.append("<a href='' class='fred'></a>");

http://api.jquery.com/append/

Upvotes: 5

Related Questions