Combining jQuery with native JS in DOM creation

I'm reusing an old application of mine and want to change the code so I'm applying the DOM structure that I build up to a node's class instead of it's id.

Below is a piece of the code and as you can see I try to combine jQuery (getting the node by it's class) with the old structure, but something doesn't work properly here.

Is it possible to combine jQuery and JS native like this? If not, is there another way to accomplish what I want to do?

var gamearea = $('<div/>', {
    text': 'testarea',
    class': 'gamearea'

alert("this.rows: " + this.rows);

for (var j = 0; j < this.rows; j++){
    var box = document.createElement('div');
    for (var i = 0; i < this.cols; i++){

        var iterator = (this.cols * j) + i;

        var img = document.createElement('img');
        var aNod = document.createElement('a');

        aNod.href = "#";
        img.src = "pics/0.png";



You should be able to get it working by changing gamearea.appendChild(box); to gamearea[0].appendChild(box);

The reason behind that is you can get the bare DOM element for a jQuery extended object by simply doing obj[0], where obj is a jQuery extended object obtained like obj = $(...) etc. And the appendChild method in your code is a method of bare DOM element.

Need Your Help

Mainform textbox referencing combo box in subform on Microsoft Access

ms-access combobox textbox

Quick question to do with Microsoft access. I've only been using it for about a week, so theres a lot i dont know.

How to change one-to-one relationship to one-to-many relationship in MySQL?

sql mysql one-to-many lastinsertid multiple-insert

I currently have a user's table which contains a one-to-one relationship for Youtube OAuth tokens. However, I now want to support multiple video sites and want to break this into a one-to-many

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.