I have the following code:
$(function () {
var target = $('span.slider') //can I make the variable apply to the target span?
target.mousedown(function() {
sliding = true
})
$(document).mouseup(function() {
sliding = false
})
$(document).mousemove(function(e) {
if(sliding){
target.css('left', e.pageX) //do I isolate here?
}
})
})
There are four ‘span.slider’ in my html. How do I modify this jquery so that the functionality only applies to the target span.slider? The code above moves all four spans, and I completely understand why it does. I am having trouble targeting it to just the span the user wishes to move.
Try this: