jQuery addClass example

Change class name on click in jQuery

by VidushiGupta

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
    <div id="filterBar" contenteditable="true">
    <span>This</span>
    <span>is</span>
    <span>test</span>
    <span>You can type here</span>
    </div>

    <br/>
    <!-- This DOES NOT move the cursor along with drag element -->
    <span id="dragOsversion" class="slipstream-secondary-button">Jquery Drag me - Not moving cursor </span>
    

    <br/>
    <br/>
    <br/>
            
    <a href="#" draggable="true">Native Drag me</a> <!-- This moves the cursor along with drag element -->

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
  color: white;
}

a {
  background: #fff;
  text-align: center;
}

#filterBar {
  border: 1px cyan solid;
  color:cyan;
  line-height: 50px;
}

JavaScript

$("#dragOsversion").draggable({helper: 'clone'});