简体   繁体   中英

jquery error on appending html content to div tag

Here is the code I am having:

<div id="removequestions"></div>

var html += '<input type=radio name=questions />';
$.('#removequestions').append(html);

The javascript error I am getting on executng the above code is:

XML filter is applied to non-XML value (function (a, b) {return new c.fn.init(a, b);})

Any idea why this error occurs. I want to add radio button dynamically.

Represent this way:-

var html = "";

html += '<input type=radio name=questions />';
$('#removequestions').append(html);​

EDIT:

Another Best way of Representation:-

var ques = $('#removequestions');
$('<input>').attr({
    'type': 'radio',
    'name': 'questions'
}).appendTo(ques);

LIVE DEMO

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM