我正在尝试在我的表格中创建一个新的
JS:
function addElement() {
var message = document.getElementById('inputsend');
var now = new Date();
var table = document.getElementById('messagebox');
var tr = document.createElement('tr');
var tdTime = document.createElement('td');
tdTime.innerHTML = now.getHours() +":"+now.getMinutes() + " ";
var tdName = document.createElement('td');
tdName = userName + " ";
var tdMessage = document.createElement('td');
tdMessage = message;
tr.appendChild(tdTime);
tr.appendChild(tdName);
tr.appendChild(tdMessage);
table.appendChild(tr);
document.getElementById('inputsend').value = "";
}
HTML:
<table id="messagebox">
</table>
但它不起作用,并且chrome说无法在节点上执行appendchild
答案 0 :(得分:0)
.innerHTML
&amp; tdName
中缺少tdMessage
appendChild
,因此您将字符串传递给无法处理的var tdName = document.createElement('td');
tdName.innerHTML = userName + " ";
var tdMessage = document.createElement('td');
tdMessage.innerHTML = message;
。
$regex_ipv4 = '((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(?![\\d])';
$regex_integer = '(\\d+)';
$x = "123.123.123.123";
$x2 = $x . ":12345";
preg_match("/^(?<ipv4>".$regex_ipv4.")(:)(?<port>".$regex_integer.")$/is", $x, $matches1);
preg_match("/^(?<ipv4>".$regex_ipv4.")(:)(?<port>".$regex_integer.")$/is", $x2, $matches2);
print_r($matches1);
print_r($matches2);