Reputation: 38422
Suggest a better way to do the following in jquery . also give me the native js code to do it
$('<div id="dialog-confirm" title="'+confirmbox.title+'"><p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>'+confirmbox.message+'</p></div>')
.appendTo('body');
Why the need. look at "Idiomatic Syntax for Creating Elements" section of this link https://stackoverflow.com/tags/jquery/info
Upvotes: 0
Views: 479
Reputation: 40639
see example here
Upvotes: 0
Reputation: 76910
youc colud create the elements in this way:
var div $('<div>', { id: "dialog-confirm", title: confirmbox.title});
var p = $('<p>');
p.text(confirmbox.message);
var span = $('<span>').addClass('ui-icon ui-icon-alert').css({ float: "left", margin: "0 7px 20px 0"});
p.prepend(span);
div.append(p);
and then append them as needed
Upvotes: 1