Welcome Guest, Not a member yet? Register   Sign In
jQuery - Adding new input boxes
#3

[eluser]cahva[/eluser]
[quote author="pianoman993" date="1269739679"]$(document).ready(function() {

});

needs to contain ALL of your jQuery not just your event listeners.
[/quote]

Sorry but that is bullcrap Smile You can place the function outside if you want.
The reason why it didnt work is how you did the append. In JS you cant create multiline variables like that. Instead you have to "glue" the lines together like this:
Code:
function addItem(){
    $('#divItems').append('<label for="item[]">Item description</label>'
        + '&lt;input type="text" name="item[]" id="item[]" class="short" /&gt;'
        + '<em>E.g. Repairs - 5 hours @ &pound;10 /hr</em>'
        + '<label for="price[]">Price</label>'
        + '&lt;input type="text" name="price[]" id="price[]" class="short" /&gt;'
    );
}


Messages In This Thread
jQuery - Adding new input boxes - by El Forum - 03-27-2010, 01:12 PM
jQuery - Adding new input boxes - by El Forum - 03-27-2010, 02:27 PM
jQuery - Adding new input boxes - by El Forum - 03-27-2010, 03:03 PM
jQuery - Adding new input boxes - by El Forum - 03-27-2010, 08:04 PM
jQuery - Adding new input boxes - by El Forum - 03-27-2010, 08:13 PM
jQuery - Adding new input boxes - by El Forum - 10-27-2010, 08:48 AM
jQuery - Adding new input boxes - by El Forum - 10-27-2010, 09:17 AM
jQuery - Adding new input boxes - by El Forum - 10-27-2010, 09:27 AM
jQuery - Adding new input boxes - by El Forum - 10-27-2010, 09:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB