-
Notifications
You must be signed in to change notification settings - Fork 5
/
anything.html
40 lines (40 loc) · 1.37 KB
/
anything.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Anything.html</title>
<style type="text/css">
.container { margin: 0 auto; width: 72%; }
.container button { float: right; }
.container textarea { margin: 10px 0; width: 100%; height: 600px; }
.fakeContainer { width: 100%; height: 100%; position: relative; }
.fakeContainer button { position: fixed; top: 0; right: 0; }
</style>
</head>
<body>
<div class="container">
<button>Show »</button>
<textarea></textarea>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script type="text/javascript">
var $container = $(".container");
var $textarea = $(".container > textarea");
$(".container > button").click(function () {
if ($textarea.val() === '') {
alert('Please add some html and press the button!');
return;
}
$container.siblings().remove();
var $anything = $('<div class="fakeContainer">'+$textarea.val()+'<button>« Back</button></div>');
console.log($anything);
$container.after($anything);
$container.hide();
$(".fakeContainer > button").click(function () {
$(this).parent().remove();
$container.show();
});
});
</script>
</body>
</html>