Is there a method to include more than one value at a time. Firstly, here is the script:
$(document).ready(function() {
$('.edit_link').click(function() {
$('.text_wrapper').hide();
var data=$('.text_wrapper').html();
$('.edit').show();
$('.editbox').html(data);
$('.editbox').focus();
});
$(".editbox").mouseup(function() {
return false
});
$(".editbox").change(function() {
$('.edit').hide();
var boxval = $(".editbox").val();
var dataString = 'data=' + boxval;
$.ajax({
type: "POST",
url: "update_profile_ajax.php",
data: dataString,
cache: false,
success: function(html) {
$('.text_wrapper').html(boxval);
$('.text_wrapper').show();
}
});
});
$(document).mouseup(function() {
$('.edit').hide();
$('.text_wrapper').show();
});
});
I want to have more than one field. I want to edit more than one entry at a time, instead of simply re-writing the code for each different value. Is there a way I can include them in the code? I tried this but had no luck:
$('.edit_link','.edit_link2','.edit_link3').click(function() {
$('.text_wrapper','.text_wrapper2','.text_wrapper3').hide();
var data=$('.text_wrapper','.text_wrapper2','.text_wrapper3').html();
Hopefully you get what I mean by this, I want to include more values but cannot achieve this, does anyone have some advice or a simply way to do this?
Put all in one string, for example:
$('.text_wrapper, .text_wrapper2, .text_wrapper3').hide();
But you can't read out the values with html()
on multiple elements at the same time.
So for example use:
data = $('.text_wrapper').html();
data += $('.text_wrapper2').html();
data += $('.text_wrapper3').html();
But this depends on how you wanna have your data in the end.