-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
38 lines (38 loc) · 931 Bytes
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Javascript ile Karakterleri Rastgele Renklendirme Uygulaması</title>
<style type="text/css">
span
{
color: red;
font-weight: bold;
font-size: 20px;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
$( 'span' ).each(function( index ) {
var originalText = $( this ).text();
var newText = '';
var color = '';
for( var i = 0; i < originalText.length; i++)
{
color = '#'+Math.floor(Math.random()*16777215).toString(16);
if (i % 2 === 0)
newText += '<span style="color: '+color+'">' + originalText.charAt(i) + '</span>';
else
newText += originalText.charAt(i);
}
$( this ).html(newText);
});
});
</script>
</head>
<body>
<span>write less do more.</span>
<br/>
<span>Kerem Bahçıvan</span>
</body>
</html>