Steve
Steve

Reputation: 4898

Not able to insert HTML

Does anyone see why the $('' line breaks the jQuery below? There's a jsfiddle here: http://jsfiddle.net/8ZBRP/2/. If you comment out the $('div') line the code at least compiles and hits the debugger line when you right-click #box.

$(function() {

    $('#box').contextmenu(function(e) {
        e.preventDefault();
        var document_offset;
        debugger;
        doc_offset = $(this).offset();
        $('<div>').css({width:150px, height:150px});
     });
});

Thanks

Upvotes: 0

Views: 73

Answers (2)

Afzaal Ahmad Zeeshan
Afzaal Ahmad Zeeshan

Reputation: 15860

Shouldn't you be using this:

$('div').css({width:"150px", height:"150px"});

instead of:

$('<div>').css({width:150px, height:150px});

Or try to qoute the styles. However, I have not tried using the angle brackets but still try it.

Upvotes: -1

James Montagne
James Montagne

Reputation: 78650

$('<div>').css({width:"150px", height:"150px"});

unquoted strings.

Upvotes: 4

Related Questions