Your 'div' is just a variable, not an element.
Use the id instead:
$("#myDiv").css("border", "1px solid red");
Here with explanations and the proper way to store an element:
// here you create a object that has no connection to the dom
var div =$('<div id="myDiv"></div>').css("border", "1px solid black");
// here you add a object to the dom that has the same values as your object - but it's a seperate entity
$("#text1").wrap(div);
// here you only update your first object - it will never reflect on it's twin in the dom -
// so remove this line:
// div.css("border", "1px solid red");
// so instead, save the real element to your variable
div = $("#myDiv");
// now you can work with it and it will update in the dom!
div.css("border", "1px solid red");
// you also need to know that since this is now a real div in your dom, you need to explicitly state which border you want:
// https://stackoverflow.com/questions/3787502/how-to-get-border-width-in-jquery-javascript
alert(div.css("border-left-color"));
var div =$('<div id="myDiv"></div>').css("border", "1px solid black");
$("#text1").wrap(div);
div = $("#myDiv");
div.css("border", "1px solid red");
alert(div.css("border-left-color"));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="text1">Text1</div>