Click here to Skip to main content
15,880,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I know this has been asked in different ways but I cannot find a solution to this. How do I drag to select multiple cells in a table on a mobile device?

What I mean is something like this: JSFiddle link, but on a mobile device.

Here is the method that I am after:

JavaScript
<script type="text/javascript" charset="utf-8">
                $(function () {
                    var isMouseDown = false;
                    $("#our_table td")
                        .mousedown(function () {
                            isMouseDown = true;
                            $(this).toggleClass("highlighted");
                            return false; // prevent text selection
                        })
                        .mouseover(function () {
                            if (isMouseDown) {
                                $(this).toggleClass("highlighted");
                            }
                        })
                        .bind("selectstart", function () {
                            return false; // prevent text selection in IE
                        });

                    $(document)
                        .mouseup(function () {
                            isMouseDown = false;
                        });
                });
            </script>


What I have tried:

I've tried replacing the methods with ontouchstart. ontouchmove, and ontouchend but none work.
Posted
Updated 3-Feb-21 3:05am

1 solution

Probably have to work with touchstart, touchmove, touchend

touchstart Event[^]
 
Share this answer
 
Comments
OneSpiked 8-Feb-21 2:22am    
I've tried all the touch events and none worked

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900