Не работает, пишет script.js:27 Uncaught TypeError: Cannot read property 'addEventListener' of null at script.js:27
'use strict'
var item = {
id: 0,
name: 'полифепан',
sinonym: ['смекта', 'фтизиин'],
creater: 'Микромакс',
mailer: 'Гротес',
cost: 140,
date: '10.19',
cost_gr: 125
}
var search = document.querySelector('input[name="search"]');
var table_search = document.querySelector('#search');
var search_p = document.queryпуеSelector('#search_p');
var sub_search = document.querySelector('#sub_search');
search.addEventListener('input', function () {
var regexp = new RegExp("(" + search.value + ")", "gi");
if (regexp.test(item.name)) table_search.innerHTML = '<tr><td><p id="search_p">' + item.name + '</p></td><td>' + item.sinonym + '</td></tr>';
else table_search.innerHTML = '<tr><td>Данный компонент не найден</td></tr>';
});
search_p.addEventListener('click', function () {
sub_search.innerHTML = '<tr><td>' + item.name + '</td><td>' + item.creater + '</td><td>' + item.mailer + '</td><td>' + item.cost + '</td><td>' + item.date + '</td><td>' + item.cost_gr + '</td></tr>';
});
<!doctype html>
<title>Поиск</title>
<input type="search" name="search" placeholder="что вы ищите?">
<table id="search">
</table>
<table id="sub_search">
</table>
<script src="script.js" defer></script>