Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete a div or span with a id=".xxx"

Tags:

html

jquery

css

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

like image 883
X10nD Avatar asked Nov 30 '22 18:11

X10nD


2 Answers

IDs can't start with a dot and can't contain an asterisk. For more information read this answer from dgvid.

like image 102
Gert Grenander Avatar answered Dec 09 '22 20:12

Gert Grenander


$("[id='*xxx.']").remove(); or just write proper identifiers.

like image 33
Babiker Avatar answered Dec 09 '22 21:12

Babiker