Hi can someone please tell me why this code is incorrect? I’m trying to pass two variable values to a function.
$( "#resizable-text1, #resizable-text2" ).draggable({
containment: "#containment-wrapper1",
scroll: false,
stop: function(event, ui)
{
var id = $(this).attr('data-idSuffix');
adjust_pos($('#resizable-text',id));
}
});
function adjust_pos(elem, id) {
alert('elem = '+elem)
alert('id = '+id)
var currentPos = $("#"+elem+id).position()
var xpos = parseInt(currentPos.left)
var ypos = parseInt(currentPos.top)
then use variables ele and id...
}
Any help appreciated.
You don’t need to wrap the string in the jQuery
$()function, because in your function you will do that anyways ($("#"+elem+id).position()). Simply send the string.So this should work:
EDIT: Also, either in your function
adjust_posor in the parameter you pass you should remove a#because otherwise there would be two. I recommend you remove in the function, so if for some reason you want to send a class selector, you can do that too.