Reputation: 6403
I'm trying to get the content of a textarea inside a sortable item in jQuery... I can't seem to figure it out! Here's what I have now:
jQuery(document).ready(function() {
jQuery("#list").sortable({
axis : 'y' ,
revert : 'true' ,
opacity : 0.5 ,
stop : function (e, ui) {
jQuery("input#output");
}
});
});
This has to be so simple I'll smack my own head when I find out how to do it, but saying that, I just can't figure it out. Can anyone help?
Upvotes: 1
Views: 1404
Reputation: 8681
ui in the stop function holds the just moved sortable at ui.item.
ui.item.children("textarea.output").val(); //whatever one you may need.
ui.item.children(".output").val();
ui.item.children("textarea").val();
I also changed "#output" to ".output" because it is standard practice not to have multiple elements with the same id (assuming that there is a textbox with an id of output in each of your sortable items.) If they are similar elements, make them the same class instead.
Upvotes: 1
Reputation: 114876
Just thinking about something you can try (without looking at your html markup)
jQuery(this).children('textarea#output').val();
jQuery(this).children('#output').val(); // this line may be all you need as well
Upvotes: 2
Reputation: 6200
EDIT: For a textarea, the "input#output" selector does not work. This only works for a TextBox. To access the contents just add .val()
jQuery(this).children("textarea#output").val(); //for a textarea
jQuery(this).children("input#output").val(); //for a textbox
Upvotes: 1