我无法删除 ID 带有句号或星号的 div。
<div id="*xxx."></div>
<div id=".xxx*"></div>
我有 jquery 代码,它删除了 <div id="xxx"></div>
但不是以上。不查找 jQuery 代码,但它是否需要正斜杠?
----anurag 的要求--------
// JavaScript
$('.s').click(function (e) {
var wd_del = (e.target.id);
var yy = wd_del.substr(1, 100);
$(document.getElementById("" + yy)).remove();
$(document.getElementById("s" + yy)).remove();
});
// HTML
<div id="s_t">
<? do { $w1=$ row_ws1[ 'wd']; ?>
<div id="<? echo $w1 ?>" class="ul_shh" style="cursor:pointer;">
<span id="s<? echo $w1 ?>" class="s">
x
</span>
<? echo $w1; ?>
</div>
<? } while ($row_ws1=m ysql_fetch_assoc($ws1)); ?>
</div>
谢谢 让
最佳答案
ID 不能以点开头,也不能包含星号。有关更多信息,请阅读此 answer from dgvid .
关于jquery - 删除 ID 为 =".xxx"的 div 或 span,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3124535/