you can do it like this:
$('.modal-content').append('<div class="modal-body step-' + key + '" data-step="'+key+'"></div>');
$('.step-' + key).append(input);
unless you expect to have multiple divs
with step+key. semantically you should use id
for the unique part anyway.
edit: ok then do it like this, if you must:
$('.modal-content').append('<div class="modal-body step-' + key + '" data-step="'+key+'"></div>');
$('.modal_body.step-' + key).append(input);
here is a link to tell you why you need the extra .
in there.
here is the relevant example from that link:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>class demo</title>
<style>
div, span {
width: 120px;
height: 40px;
float: left;
padding: 10px;
margin: 10px;
background-color: #EEEEEE;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div class="myclass">div class="notMe"</div>
<div class="myclass otherclass">div class="myClass"</div>
<span class="myclass otherclass">span class="myClass"</span>
<script>
$( ".myclass.otherclass" ).css( "border", "13px solid red" );
</script>
</body>
</html>