Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 907067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:29:31+00:00 2026-05-15T16:29:31+00:00

I am unable to delete a div with an id with a period or

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:29:33+00:00Added an answer on May 15, 2026 at 4:29 pm

    Alternate Approach

    I think you can do without messing around with any id’s at all. Rely on the document structure instead to provide the information. It looks like you have a list of divs, where each div can be deleted by clicking on an x that is present inside the div.

    So if you had a structure like:

    <div class="node">
        <span class="delete"> x </span>
        ...
    </div>
    <div class="node">
        <span class="delete"> x </span>
        ..
    </div>
    

    Assign the delete event to all spans as,

    $("span.delete").click(function() {
        $(this).parent('.node').remove();
    });
    

    That should free you from having to rely on the id at all, as long as you stick to a basic structure of putting the span inside the div and assign appropriate class names. If you want to know the ID of the clicked element’s parent, store it as a data attribute instead of an id. That keeps jQuery and older browsers happy. For example,

    <div class="node" data-id="*xxx.">
        ...
    </div>
    

    which can be retrieved inside the span click handler, as:

    $("span.delete").click(function() {
        var node = $(this).parent('.node');
        var id = node.attr('data-id'); // do something with it
    });
    

    Old Approach

    Query using the native getElementById method to ensure that the element gets selected if the user-agent considers that to be a valid ID. jQuery will do some extra processing on the passed in ID, so it’s better to query natively:

    $(document.getElementById("*xxx.")).remove();
    $(document.getElementById(".xxx*")).remove();
    

    Or escape the characters * and . with \\. Here’s a jQuery-esque solution

    $("#\\*xxx\\.").remove();
    $("#\\.xxx\\*").remove();
    

    Works on all moojor browsers for me. Do IE tests yourself 🙂 See this example.

    Note, that the restrictions for what constitutes a valid ID string as per HTML5 are:

    1. Must be unique
    2. Must contain at least one character
    3. Must not contain any space character

    Quoting from the spec:

    The id attribute specifies its element’s unique identifier (ID). The value must be unique amongst all the IDs in the element’s home subtree and must contain at least one character. The value must not contain any space characters.

    If the value is not the empty string, user agents must associate the element with the given value (exactly, including any space characters) for the purposes of ID matching within the element’s home subtree (e.g. for selectors in CSS or for the getElementById() method in the DOM).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm unable to delete my file, i have looked here but can't find the
I have the following link which opens a jquery modal window: <div id='confirm-dialog'><a href='#'
I have tried many ways to achieve this biut unable to delete row from
I have created installer which needs to delete some files and folder if they
I'm unable to delete a folder in Windows with the following code: SHFILEOPSTRUCT shfo
I have the following jquery code in my view <script type=text/javascript> $(document).ready(function () {
Apparently, NSFileManager is unable to delete files created by mkstemp() . Here's some test
I am unable to change my max execution time. I have changed it in
What's wrong with this code? I'm not able to validate 'data': $.post('http://localhost/do.php', function(data) {
I have the following method that drops the database but I get a syntax

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.