How to generate a element dynamically after a specific element

I am generating a textfield dynamically using javascript. The problem is that the new textfield is generated before the file type. I want to generate it after the file type and in a new row. i Have shared the code.

html

<input type="text" name="textf"/>

http://jsfiddle.net/QxPbJ/2/

Hope you understand

Thanks in advance

Answers


You are not using table but you are appending tr and td. First place table after the field and add tr to it


Try this link Click here

Html

<input type="radio" name="choices"/>
<input style="margin-bottom:20px;"id="option1" class="ABC" name="option1"type="text"/>
<input type="file" name="op" id="op"/>
<div id="appendBefore"></div>

Js

$(function () {
  count = 2;
  var createNewField = function() {
  var $node = $('<tr><td></td><td><input type="radio" name="choices" name="o" id="o"     style="float:left"/><div class="XYZ" style="float:left"><input style="margin-bottom:20px; " class="ABC" type="text" name="option" id="option" placeholder="add option '+count+'"/>   </div>&emsp;<input type="file"/></td></tr>');
  if(count < 6){
    $node.find("input.ABC").one('click', createNewField);
    $('#appendBefore').before($node);
    count = count+1;
  }
};
$('input.ABC').one('click', createNewField);
});

Do you mean something like this?

$(function () {
    count = 2;
    var createNewField = function () {
        var node = $('<tr><td></td><td><input type="radio" name="choices" name="o" id="o" style="float:left"/><div class="XYZ" style="float:left"><input style="margin-bottom:20px; " class="ABC" type="text" name="option" id="option" placeholder="add option' + count + '"/></div>&emsp;<input type="file"/></td></tr>');
        if (count < 6) {
            $('input').last().after(node);
            count++;
            node.click(function () {
                createNewField();
            });
        };
    };
    $('input.ABC').click(function () {
        createNewField();
    });
}); 

Need Your Help

enable / disable fields based on previous options

jquery html5

I am trying to create a form that will gray out the States list if the user selects a Country other then the US. So this is what I have:

Python Django Admin Clean() Method not overiding values

python django admin

Maybe I am missing something here, but according to the django docs, I should be able to overide values sent from an admin form from within the clean() method.

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.