Php 图像标记中的ID失败
尝试设置Php 图像标记中的ID失败,php,html,key-value,Php,Html,Key Value,尝试设置id=$x-但失败 <img src='images/Rename.png' id='".$x."' title='Create new item' border=0 width='20px' height='20px' class='item_create_button'> 它在Firebug中显示id=1 为什么我不能将img标签中的id设置为任何值 以下是正确的语法 for ($x=0; $x<100; $x++) { echo "<input ty
id=$x
-但失败
<img src='images/Rename.png' id='".$x."' title='Create new item' border=0 width='20px' height='20px' class='item_create_button'>
它在Firebug中显示id=1
为什么我不能将img标签中的id设置为任何值 以下是正确的语法
for ($x=0; $x<100; $x++) {
echo "<input type=button id='".$x."' title='Create new item' border=0 width='20px' height='20px' class='item_create_button'>";
}
用于($x=0;$x这是一个不错的答案,除了ID的“可能”不应该以数字开头。以“-”或“可能”开头是可以的。以字母开头是最安全的。是的,它是正确的。但是我希望和而不是@osomanden CSS ID不能以数字开头。-但是它们可以包含数字,所以请以字母作为前缀。@JAL让我们只-为了论证,-说我意识到了这一点,并且试图不管它,设置一个ID=SoMeValue.如果我在一个输入标签上做的话,ID被正确地设置(即使我用eg. A.预置它,所以我只是用前缀来尝试它:代码:它仍然在显示——如果你认为我的答案是正确的,你能把它标记为正确吗?
for ($x=0; $x<100; $x++) {
echo "<input type=button id='".$x."' title='Create new item' border=0 width='20px' height='20px' class='item_create_button'>";
}