Using JQuery, is it possible to add all members of one class to another class? Here, I’m trying to add all members of the class ui-widget-content to the class draggable.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Draggable - Auto-scroll</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<style>
#draggable, #draggable2, #draggable3 { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 0 10px 10px 0; }
</style>
<script>
$(function() {
$(".draggable").draggable({ scroll: true });
});
</script>
</head>
<body>
<div id="draggable" class="ui-widget-content">
<p>Scroll set to true, default settings</p>
</div>
<div style="height: 5000px; width: 1px;"></div>
</body>
</html>
You can use the .addClass() method to add the specified class..
If you want to add the class to the specified div’s based on id’s you can do it this way
Check Fiddle