Dear All,

I am trying to store a predefined div with a class in a variable using jQuery, Please find my below code and let me know whether it is right or not.

loader : $("<div/> + {class:'test'}")

thanks in advance.

Recommended Answers

Please find my below code and let me know whether it is right or not.

Can't answer your question regarding about your code because you didn't provided enough code to determine whether it works or not.

So this is the only code that I can think of:

jQuery:

Jump to Post

All 2 Replies

Member Avatar

Please find my below code and let me know whether it is right or not.

Can't answer your question regarding about your code because you didn't provided enough code to determine whether it works or not.

So this is the only code that I can think of:

jQuery:

var vname = 'This is my variable';

$('#variable').prepend('<div id="' + vname + '">'+ vname +'</div>');

html:

<div id="variable">variable</div>

hey lastMitch,

thanks for your respone, that is fine. But my question is whether it is the right format .I saw one. like this.

Code is like

    res
    {
    loader : $("<div/> + {class:'test'}")
    }

    res.loader.append('somediv');
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.