pankajrathod84
asked on
How to add dynamic element to DIV using Jquery or Ajax
HI,
I am having requirement to add textbox radio button and input button dynamically in page. Text box is to add email radio to select primary email and button to delete email row. By clicking on Add new button a new row should be added.
All this I have to do without submitting form. So have to use jquery or Ajax.
Please help.
I am having requirement to add textbox radio button and input button dynamically in page. Text box is to add email radio to select primary email and button to delete email row. By clicking on Add new button a new row should be added.
All this I have to do without submitting form. So have to use jquery or Ajax.
Please help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
function addElement() {
var ni = document.getElementById('m
var numi = document.getElementById('t
var num = (document.getElementById('
numi.value = num;
var newdiv = document.createElement('di
var divIdName = 'my'+num+'Div';
newdiv.setAttribute('id',d
newdiv.innerHTML = 'Element Number '+num+' has been added! <a href=\'#\' onclick=\'removeElement('+
ni.appendChild(newdiv);
}
or
function addTextBox()
{
var txtHolder = document.createElement('di
var txtBox = document.createElement('in
txtBox.id = "dynaTxtBox_"+txtCount;
txtBox.className = "dynaTxtBox";
txtBox.value = txtCount;// This line is not necessary
txtHolder.appendChild(txtB
document.getElementById('t
txtCount++;
}