jquery.selection icon indicating copy to clipboard operation
jquery.selection copied to clipboard

Uncaught TypeError: Cannot read property 'substr' of undefined

Open onet4 opened this issue 8 years ago • 0 comments

Hi, looks like a nice plugin.

It seems this plugin cannot modify normal html text.

When you select words in the following example, you get an error, Uncaught TypeError: Cannot read property 'substr' of undefined.

<html>
<head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
    <script type="text/javascript" src="src/jquery.selection.js"></script>

</head>

<body>

    <div class="content">

        <p id="laten-text">Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts.</p>

    </div>

    <script>

        $( document ).ready( function() {

            $( '.content p' ).click(function(){                           
                $( this )
                    .selection('insert', {text: '<strong>', mode: 'before'})
                    .selection('insert', {text: '</strong>', mode: 'after'});

            });

        });

    </script>

</body>
</html>

onet4 avatar Jun 22 '16 08:06 onet4