Get values of previously generated input fields
It's not possible to get an input value with jQuery, when you've previously generated that input field (with value), in another function?
function 1: generate input fields with values
function 2: get values of those input fields
I know the syntax of getting the values of input fields, but I can only get values of static input fields.
If it however IS possible, can someone explain me how to do this?
It depends how you are dynamically creating the elements.
If you are adding them to the DOM properly, then normal value retreival methods should be fine (treat them as static entries)
However if you are just adding the HTML, via something like .innerHTML, then, well, don't :thumbsup:
I'm using a toggle button to add or remove a table row with the containing input field and value.
I'm adding the row using .after()
I'm able to get those values within the same function, but not in a new click function outside the toggle function.
Update: I "hardcoded" the table row into my html document, and then I'm able to get the input value.
However, if I add this row with jQuery .after(), I cannot get that value.
How do I solve this?
Replace your click function with .live() - so instead of:
Could you explain to me why click doesn't work this way?
I also tried .live() with toggle, but that doesn't seem to work?
$(selector.click() will attach an event handler to all current elements which match selector, whereas .live() allows you to extend this to elements which match now or in the future.
.live works with events - so click, mouseover, mouseout etc will work, but toggle won't because it isn't an event.
Thanks for the help and info SB65!
|All times are GMT +1. The time now is 03:52 PM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.