Skip to content

Commit

Permalink
update 170322 17:07
Browse files Browse the repository at this point in the history
  • Loading branch information
SPxiaomin committed Mar 22, 2017
1 parent deb2300 commit dd168d9
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
44 changes: 44 additions & 0 deletions react-tab-selector/tab-selector-jquery/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
html {
font-size: 62.5%;
}

body {
font-size: 1.4rem;
}

.tab-selector {
margin: 50px;
}

.tab-selector {
overflow: hidden;
}

.tab-selector label {
float: left;
margin-right: 10px;
padding: 5px;
text-align: left;
font-weight: bold;
}

.tab-selector ul {
margin: 0;
padding: 0;
list-style: none;
}

.tab-selector li {
cursor: pointer;
float: left;
padding: 5px 15px;
border: 1px solid #ddd;
margin: 0 10px;
list-style: none;
}

.tab-selector li.selected {
border-color: #2175bc;
background-color: #2175bc;
color: #fff;
}
44 changes: 44 additions & 0 deletions react-tab-selector/tab-selector-jquery/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>tab selector jquery</title>
<link rel="stylesheet" href="./index.css">
<script src="./jquery-3.2.0.min.js" charset="utf-8"></script>
</head>
<body>
<div id="container"></div>
<script>
var data = [
{name: 'Red', value: 'red'},
{name: 'Blue', value: 'blue'},
{name: 'Yellow', value: 'yellow'},
{name: 'Green', value: 'green'},
{name: 'White', value: 'white'}
];

$.fn.TabSelector = function(options) {
// DOM 构建
var arr = [];
arr.push('<div class="tab-selector">');
arr.push('<label>', options.label, '</label>');
arr.push('<ul>');
options.data.forEach(function(item) {
arr.push('<li data-value="', item.value, '">');
arr.push(item.name);
arr.push('</li>')
});
arr.push('</ul>');

this.html(arr.join(''));

// 交互

};

$('#container').TabSelector({data: data, selected: null, label: 'Color'})
</script>
</body>
</html>

0 comments on commit dd168d9

Please sign in to comment.