Помогите с таблицей
Вот код
<html>
<head>
<title></title>
<script>
var table ='<center><h2 style="margin-left: 18%;"> Машины в нашем гараже</h2><button>Каталог Машин</button></center>';
var cars = [
['Hyundai','Tucson','White',1999,5000],
['Toyota', 'Toyota Land Cruiser 100','Yellow', 1995,3000],
['Lexus', 'GS 300','Black', 1991,2000]
]
table += '<table class="table"><tr class="tb_th"><th>Марка</th> <th>Модель</th><th>Цвет</th><th>Год выпуска</th><th>Цена</th></tr>';
for (var i = 0; i < cars.length; i++){
table += '<tr class="tb_th"><td class="tb-td">'+cars[i][0]+'</td> <td>'+cars[i][1]+'</td><td>'+cars[i][2]+'</td><td>'+cars[i][3]+'</td>';
if (cars[i][4] > 3000){
table += '<td class="dorogoi">'+cars[i][4]+' ▲</td></tr>';
} else
table += '<td class="deshovii">'+cars[i][4]+' ▼</td></tr>'
}
table += '</table>';
document.write(table)
</script>
<style>
body{
background-color:#0e0e0e;
}
.table {
width:50%;
height:20%;
margin:0 0%;
border-collapse: collapse;
border: 2px solid transparent;
}
.table tr th {
text-align:left;
color: #4d4d4d;
}
.table .tb_th {
background: #1a1a1a;
}
.table tr td {
color: #444444;
}
.table tr {
background: #1d1d1d;
border-top: 2px solid #232323;
border-bottom: 2px solid #232323;
}
.table tr .tb-td {
color: #b5b5b5;
}
.table tr .dorogoi {
color: #cd3e4a;
}
.table tr .deshovii {
color: #84b547;
}
h2 {
color: white;
text-align: left;
}
</style>
</head>
<body>
</body>
<html>
Нужно сделать так чтобы при нажатии на кнопку эта же графа появлялась рядом правой стороны. |
Цитата:
|
|
Так понятнее наверно https://codepen.io/Sirius89/pen/oWPJMg
по нажатию на кнопку нужно чтоб он с правой стороны выводил эту же таблицу. |
Цитата:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1251' />
<script src='http://code.jquery.com/jquery-latest.js'></script>
<!--
<script src="https://code.angularjs.org/1.3.9/angular.min.js"></script>
<script src="https://code.angularjs.org/1.3.9/angular-route.js"></script>
-->
<style type='text/css'>
.hide_block{
display: none;
}
</style>
<script type='text/javascript'>
$(function(){
$('.toggle').click(function(){
$(this).parent().parent().find('.hide_block').toggle(400);
});
});
</script>
</head>
<body>
<table style="width: 100%;" border="1">
<tbody>
<tr>
<td style="width: 200px;">
<button class="toggle">toggle button</button>
</td>
<td>
<div class="hide_block">toggle content 1</div>
</td>
</tr>
<tr>
<td>
<button class="toggle">toggle button</button>
</td>
<td>
<div class="hide_block">toggle content 2</div>
</td>
</tr>
<tr>
<td>
<button class="toggle">toggle button</button>
</td>
<td>
<div class="hide_block">toggle content 3</div>
</td>
</tr>
<tr>
<td>
<button class="toggle">toggle button</button>
</td>
<td>
<div class="hide_block">toggle content 4</div>
</td>
</tr>
</tbody>
</table>
</body>
</html>
|
Да я уже как та натыкала. Только вот не получается на вторую кнопку поставить. https://codepen.io/Sirius89/pen/eWLXxe
|
Цитата:
|
Сделала на button скрипт на который при нажатии появляется та же таблица только вот понять не могу. Как оттуда убрать некоторые элементы и добавить туда еще кнопки. Помогите пожалуйста. Очень прошу.
|
Цитата:
http://www.fpublisher.ru/documentati...s#hremovechild Цитата:
http://www.fpublisher.ru/documentati...hcreateelement и http://www.fpublisher.ru/documentati...s#happendchild http://www.fpublisher.ru/documentati...#hinsertbefore |
Цитата:
https://learn.javascript.ru/modifying-document |
| Часовой пояс GMT +3, время: 16:38. |