Home>

There are the following elements, and we want to hide them when clicking the button.
At that time, id and class attributes cannot be set manually for the element to be deleted, and we want to delete the element based on the title attribute.

Element I want to delete



Button to delete an element

<button>Click to erase</button>

I tried it with the following code, but it doesn't disappear well. If this is the case, how should I write the code?
(Note that if you set it with div, it will affect unrelated elements, so we want to identify it with title = "publish.)

Code you tried

$(function () {
    $('button'). click (function () {
        $('[title = "publish"]'). remove ();
    });
});

Or, if there is an element with title = "publish", is there a way to add an id or class element to that element?

  • Answer # 1

    Does it react normally?

    
    

    * Original source, img tag's src attribute quote is strange

  • Answer # 2

    I tried, but it disappeared normally.

    There is a possibility that the element you want to erase is mistaken.
    Make sure that the element you want to erase is really an element oftitle = "publish".