I am unable to delete a div with an id with a period or an asterix.
<div id="*xxx."></div>
<div id=".xxx*"></div>
I have the jquery code, which deletes the <div id="xxx"></div>
but not the above. Not looking for the jQuery code, but does it need a forward slash?
----req by 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>
Thanks Jean
IDs can't start with a dot and can't contain an asterisk. For more information read this answer from dgvid.
$("[id='*xxx.']").remove();
or just write proper identifiers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With